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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3844369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 09:12:35  来源:igfitidea点击:

Git production/staging server workflow

gitproductionstagingdev-to-production

提问by kayue

Currently my website (production server) already have a lot of code in it. And now I want to start using Git for my projects and setup a staging server for my team. Can anybody give me any advise?

目前我的网站(生产服务器)已经有很多代码了。现在我想开始在我的项目中使用 Git 并为我的团队设置一个临时服务器。任何人都可以给我任何建议吗?

Here is the picture in my mind:

这是我脑海中的画面:

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

My question is, how should I start?

我的问题是,我应该如何开始?

Here are some steps in my mind:

以下是我的一些步骤:

  1. do a git initin production server (is this safe?)
  2. clonethe repo from production to staging server
  3. developers clonethe repo from the staging to their local machine
  4. pushfiles to the staging server after finish changing
  5. when staging is ready, pusheverything to the production
  1. 做一个git init生产服务器(这安全吗?)
  2. clone从生产到登台服务器的回购
  3. 开发人员clone将 repo 从登台到他们的本地机器
  4. push更改完成后将文件发送到登台服务器
  5. 当舞台准备好时,push一切都在生产中

Does this work flow makes sense, or there are some better way to do it?

这个工作流程有意义吗,或者有更好的方法吗?

What if I only want to change one file?

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

Does origin/master has anything to do with it in this process?? Who is the origin? am I going to end up having multiple origins??

这个过程中origin/master有什么关系吗??谁是原点?我最终会有多个起源吗??

Also, when should a developer use branchin this case?

另外,branch在这种情况下,开发人员应该什么时候使用?

采纳答案by bUg.

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/gitflowThere is also good picture describing git branching model - http://nvie.com/posts/a-successful-git-branching-model/

最好只将 master 分支用于生产和开发分支用于登台。每个开发人员都应该创建本地分支以添加新功能,然后与开发分支合并。如果您是 git 新手,请尝试使用 - http://github.com/nvie/gitflow还有描述 git 分支模型的好图片 - http://nvie.com/posts/a-successful-git-分支模型/

回答by Felixyz

Your suggestion looks ok, but I wouldn't let the developers push directly to the staging server. Instead, an integratorshould 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.

您的建议看起来不错,但我不会让开发人员直接推送到登台服务器。相反,集成商应该仔细分支并将它们合并到主分支(或开发分支,如果您使用 bUg 建议的 git 流模型。) * 同一个人将推送到登台服务器。

* 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?)

1. 在生产服务器上做一个 git init (这安全吗?)

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.

是的,它是安全的,但是您当然必须对此存储库设置非常严格的权限。curl如果我还没有它,我可能会首先将整个网站放到本地光盘上。

2. clone the repo from production to staging server

2. 将 repo 从生产克隆到登台服务器

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

3. 开发人员将 repo 从 staging 克隆到他们的本地机器

4. push files to the staging server after finish changing

4. 修改完成后推送文件到暂存服务器

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

5. 准备就绪后,将所有内容推送到生产中

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.

用“中央”替换“暂存”,我认为你没问题,但更大的问题是你将如何处理分支和合并,正如 bUg 指出的那样。