Git 生产/登台服务器工作流

目前我的网站(生产服务器)已经有很多代码在它。 现在我想开始为我的项目使用 Git,并为我的团队设置一个登台服务器。 有人能给我点建议吗?

这是我脑海中的画面:

        Production        - Production server which already have codes
↑
Staging          - New staging server, will install Trac too
↗↙ ↖↘
Developer1  Developer2  - Local development

我的问题是,我该怎么开始?

下面是我脑海中的一些步骤:

  1. 在生产服务器中执行 git init(这安全吗?)
  2. 从生产到登台服务器的回购
  3. 开发人员 clone的回购从登台到他们的本地机器
  4. 完成更改后,将 push文件发送到登台服务器
  5. 当舞台准备就绪,push的一切到生产

这种工作流程是否有意义,还是有更好的方法来做到这一点?

如果我只想更改一个文件,该怎么办?

在这个过程中,起源/主人与它有什么关系吗? 起源是谁? 我最终会有多个起源吗? ?

此外,在这种情况下,开发人员应该何时使用 branch

30540 次浏览

It's better to use master branch only for Production and development branch for Staging. Each developer should create local branch to add new features and then merge with development branch. If you're new to a git, try to use - http://github.com/nvie/gitflow There is also good picture describing git branching model - http://nvie.com/posts/a-successful-git-branching-model/

Your suggestion looks ok, but I wouldn't let the developers push directly to the staging server. Instead, an integrator should carefully review branches and incorporate them into the main branch (or development branch if you use the git flow model as suggested by bUg.) * The same person would push to the staging server.

* Integrator: "A fairly central person acting as the integrator in a group project receives changes made by others, reviews and integrates them and publishes the result for others to use..."


1. do a git init in production server (is this safe?)

Yes it's safe, but you of course have to set very restrictive permissions on this repo. I would probably start off by curling the whole web site to a local disc, if I don't already have it.

2. clone the repo from production to staging server

You should probably have a "central" repo separate from both the production and the staging server. That one can be cloned and pushed as needed.

3. developers clone the repo from the staging to their local machine

4. push files to the staging server after finish changing

5. when staging is ready, push everything to the production

Replace "staging" with "central" and I think you're ok, but a bigger issue is how you'll work with branches and merging, as bUg points out.