使用GIT在本地服务器和活动服务器之间同步网站文件? [英] Syncing website files between local and live servers using GIT?

查看:220
本文介绍了使用GIT在本地服务器和活动服务器之间同步网站文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两台Web服务器,一台本地开发,一台现场。



在SVN下,我会将网站文件检出到我的本地web服务器的public_html目录以及实时web服务器的public_html目录中。然后,我会直接在本地服务器上处理文件,并将任何更改提交到中央存储库。



当我准备好将这些更改发布到实时服务器上时,我将SSH加入并执行SVN更新。



基本上我有两份工作副本,一份在本地,另一份在本地机器上也可以有工作副本。但是活服务器上只会有一个工作副本。原因是我们可以在每次我们想要发布更改时在实时服务器上执行SVN更新。



如何使用GIT完成同类工作流程?

解决方案

为了建模您当前的工作流程,几乎完全可以做到:


  • 设置一个git仓库。

  • 克隆服务器和本地仓库。

  • 在本地工作

  • git推送到git repo

  • ssh到服务器

  • git pull。


另一种方法是在git中建立一个生产分支,拥有一个cron作业,不断地在服务器上拉这个分支,然后合并任何时候想要发布更改时,都可以推送到生产分支。听起来你需要更具体的分支策略。



请参阅: Git流分支模型&& git flow cli工具



祝你好运!这是一个非常可以解决的问题。


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?

解决方案

To model your current work flow almost exactly do:

  • Set up a git repo.
  • Clone the repo on the server and locally.
  • Work locally
  • git push to the git repo
  • ssh to server
  • git pull.

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.

这篇关于使用GIT在本地服务器和活动服务器之间同步网站文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆