Syncing website files between local and live servers using GIT?

北慕城南 提交于 2019-12-06 13:22:49

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.

In your local working copy:

git push ssh://you@yourserver/path/to/your/wc

will push the commited changes in your local version to yourserver.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!