在这里完成我的部署方案时画一个空白。发布此问题后:将完全没有 VCS 的生产站点迁移到 Git后,我已经掌握了部署到本地存储库的要点。
我的本地开发服务器上有一个 git-flow 存储库,我可以推送到它,它将更新外部工作树。
我用 git-flow 设置了我的仓库,这就是我的原始遥控器的样子:
$ git remote show origin
* remote origin
Fetch URL: ssh://user@host/var/git/dev/repo.git
Push URL: ssh://user@host/var/git/dev/repo.git
HEAD branch (remote HEAD is ambiguous, may be one of the following):
develop
master
Remote branches:
develop tracked
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local refs configured for 'git push':
develop pushes to develop (up to date)
master pushes to master (up to date)
我试图做的是设置 2 个伪环境。一个用于分期,一个用于生产。我想让他们表现如下:
git push staging #pushes to remote staging repo with a post-receive hook "git checkout develop -f"
git push production #pushes to remote production repo with a post-receive hook "git checkout master -f"
这样,我们可以在本地开发并推送到我们的小型内部开发服务器并拥有所有历史记录。然后,当我们明确分期/生产时,我们只需推出适当的分支。
我尝试使用单独的工作树创建裸仓库,就像我对开发服务器所做的那样(请参阅帖子开头的链接),并且简单地做了:
git push staging develop
git push production master
这里分别是遥控器:
$ git remote show staging
* remote staging
Fetch URL: ssh://user@host/var/git/dev/staging.git
Push URL: ssh://user@host/var/git/dev/staging.git
HEAD branch: develop
Remote branch:
develop tracked
Local ref configured for 'git push':
develop pushes to develop (up to date)
$ git remote show production
* remote produdction
Fetch URL: ssh://user@host/var/git/dev/production.git
Push URL: ssh://user@host/var/git/dev/production.git
HEAD branch: master
Remote branch:
master tracked
Local ref configured for 'git push':
master pushes to master (up to date)
所以,理论上,我们可以在内部使用git-flow,跟踪develop分支,推送出去给其他部门查看/QA。然后我们可以在内部进行发布,并将更改推送到 staging,然后简单地将 master 分支推送到生产环境。
我想我的问题是——我这样做的方式是否正确?在 git 和 git-flow 方面,我是一个真正的新手。我已经仔细研究了所有可用的资源,这是迄今为止我能想到的最好的。
非常感谢在多阶段部署中使用 git-flow 的人们提供的任何见解。