使用 GIT 在本地服务器和实时服务器之间同步网站文件?
假设我有两台 Web 服务器,一台是本地开发的,一台是实时的。
在 SVN 下,我会将网站文件检出到本地网络服务器的 public_html 目录以及实时网络服务器的 public_html 目录。然后,我将直接在本地服务器上处理文件,并将任何更改提交到中央存储库。
当我准备好让这些更改在实时服务器上生效时,我将通过 SSH 登录并执行 SVN 更新。
本质上,我有两个工作副本,一份是实时的,一份是本地的,尽管其他用户也可能在其本地计算机上有工作副本。但实时服务器上只会有一份工作副本。这样做的原因是,每次我们想要发布更改时,我们都可以在实时服务器上执行 SVN 更新。
如何使用 GIT 完成类似的工作流程?
Say I have two web servers, one local development and one live.
Under SVN I would checkout the website files to my local webserver's public_html directory and also to the live webserver's public_html directory. I would then work on the files directly on the local server and commit any changes to the central repository.
When I'm ready for those changes to go live on the live server, I would SSH in and perform an SVN update.
Essentially I have two working copies, one on live and one locally, though other users may also have working copies on their local machines. But there will only ever be one working copy on the live server. The reason for this is so that we can just perform SVN update on live server every time we want changes to be published.
How can a simiar workflow be accomplished using GIT?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要对当前的工作流程进行几乎完全相同的建模,请执行以下操作:
另一种方法是在 git 中设置一个“生产”分支,有一个 cron 作业不断地在服务器上拉取该分支,然后在您想要发布您的内容时随时合并并推送到“生产”分支。变化。听起来您需要更具体的分支策略。
请参阅:Git 流分支模型 & & git flow cli 工具
祝你好运!这是一个用 git 可以很好解决的问题。
To model your current work flow almost exactly do:
Another way to do it would be to set up a "production" branch in git, have a cron job that continually pulls this branch on the server, and then just merge and push to the "production" branch any time you want to publish your changes. Sounds like you need a more concrete branching strategy.
See: Git flow branching model && git flow cli tool
Good luck! This is a very solvable problem with git.
您可能会发现这很有用: http://joemaller.com/990/a-以网络为中心的 git 工作流程/
You might find this useful: http://joemaller.com/990/a-web-focused-git-workflow/
在您的本地工作副本中:
将本地版本中提交的更改推送到您的服务器。
In your local working copy:
will push the commited changes in your local version to yourserver.
像 leonbloy 和 codemac 建议的那样触发自动拉动的设置乍一看似乎是个好主意,但它往往非常脆弱。我建议一个不同的选择。
http://toroid.org/ams/git-website-howto
Having a setup that triggers automatically pulling like leonbloy and codemac suggested may seem like a good idea at first but it tends to be very fragile. I suggest a different alternative.
http://toroid.org/ams/git-website-howto