Automatically synchronizing my local directories from GitHub
I have a PHP Application Development Platform that I plan to host on Github.
I'm using this platform to power about 8 or so different sites/projects on 8 different servers powered by Ubuntu开发者_高级运维. I need to keep all the files in sync (but not necessarily in realtime - maybe every 15 minutes) i.e. I commit the files to Github, and then my local directories are automatically on each of the 8 servers so that they contain the latest files.
I don't need the local directories to keep a history, I just need them to be updated to reflect the latest version of the Github repo i.e. overwrite the last set of changes with the new one, and delete any local files and directories that might have been deleted from my github repo.
Do I need to install Git on each of the 8 servers? And if so, is there a command that will enable me easily do this, so that I can wrap it in a cron job or something?
Thanks.
I think you're looking for Continuous Integration.
There are many different options to choose from, most of which can keep your servers up-to-date with the latest from Github (or any other git server for that matter)
- Jenkins (Used by Github and many other companies)
- CI Joe (Made by Github's Defunkt, written in ruby)
There are many others available, but searching "Continuous Integration" will likely find you an answer
Easiest way would be to install git on the server, then do
GIT_DIR=/path/to/your/repo (git fetch && git reset --hard origin/master)
obviously replacing origin/master with your remote and branch.
精彩评论