[英]Git production and development server workflow
I am not sure whether the git workflow I intend to create between my production and development server is the right way of doing it. 我不确定要在生产和开发服务器之间创建的git工作流程是否是正确的方法。
This is what i have in mind: Development takes place on local computers and commits are git push
to development server. 我想到的是:开发在本地计算机上进行,并且将git push
送到开发服务器。 Once a stable release is available, the production server does a git pull
from development server. 一旦有稳定的版本可用,生产服务器就会从开发服务器进行git pull
。 Any unexpected results on production can be reverted with git revert
任何意外的生产结果都可以使用git revert
Is it the correct way of doing this? 这是正确的方法吗? If so, how do I make existing code sitting on the development server, a remote repo? 如果是这样,我如何使现有代码位于开发服务器(远程仓库)上? Presumably, it's remote to both production and local as they pull
and push
. 据推测,因为它的遥控器生产和当地的pull
和push
。
Is it the correct way of doing this? 这是正确的方法吗?
Yes, that sounds completely reasonable. 是的,听起来完全合理。
If so, how do I make existing code sitting on the development server, a remote repo? 如果是这样,我如何使现有代码位于开发服务器(远程仓库)上? Presumably, it's remote to both production and local as they pull and push. 据推测,当他们进行推销时,它对于生产和本地都是遥不可及的。
Say you normally access your repo through ssh, like this: 假设您通常通过ssh访问您的存储库,如下所示:
brian@local$ ssh brian@development
brian@development$ cd /home/brian/code
brian@development$ git status
Then you can clone this code with git clone ssh://brian@development:/home/brian/code
. 然后,您可以使用git clone ssh://brian@development:/home/brian/code
克隆此git clone ssh://brian@development:/home/brian/code
。 You should be able to git push
and git pull
to and from development from then on. 从那时起,您应该能够在开发中进行git push
和git pull
。
Is it the correct way of doing this? 这是正确的方法吗? If so, how do I make existing code sitting on the development server, a remote repo? 如果是这样,我如何使现有代码位于开发服务器(远程仓库)上? Presumably, it's remote to both production and local as they
pull
andpush
. 据推测,因为它的遥控器生产和当地的pull
和push
。
Git is just a tool, there isn't any corrent way or how you use it makes it the correct way . Git是只是一个工具,没有任何corrent方式 或你如何使用它使得它的正确方法 。
For your situation: 针对您的情况:
So you can build Development git repo first, then clone to Production and Local: 因此,您可以先构建Development git repo,然后克隆到Production和Local:
user@development $ setup_git_repo.sh
user@local $ git clone ssh://user@development:/path/to/git/repo
user@production $ git clone ssh://user@development:/path/to/git/repo
Or you may clone via http: 或者您可以通过http克隆:
user@development $ setup_git_repo.sh
user@local $ git clone http://development.server/git/repo
user@production $ git clone http://production.server/git/repo
Then you have 3 git repo. 然后,您有3个git repo。 Local git repo and production git repo are cloned from development git repo. 从开发git repo克隆本地git repo和生产git repo。
Finally, you may do daily coding in local and push to development. 最后,您可以每天在本地进行编码并推动开发。 Do some test on development and release with new tag. 使用新标签对开发和发布进行一些测试。 Run git pull
on production server to get the latest code. 在生产服务器上运行git pull
以获取最新代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.