So I just want to set up Git on my server, but I'm running into a million problems so forget that.
Can I set up a normal git repo and then have my web server "auto" sync (just read, I guess) with the git repo?
I'm just part of a 2 person team and would prefer to use Git over any other version control.
You can pull from your web server, but pushing to a non-bare repository requires a number of extra steps and can create problems. The right thing to do is usually to use a webhook or deployment tool that triggers on commits to a Git repository, but there are simpler options such as server-side cron jobs.
On way to get the functionality you want is with a cron job. As a simplistic example, you could poll your git repository every minute and pull changes, e.g.:
* * * * * cd /path/to/www && git pull
If you have a web service that needs to be restarted to take advantage of modified resources, then you'd obviously need to do that too.
If you're using GitHub or other hosted repository service, you can often take advantage of integrations with providers like AWS or Heroku. In particular, Heroku is nice because each push to the master branch will recompile and redeploy your web service without requiring additional action.
For more information, see the following:
If you have more complex requirements, you probably need a more capable deployment tool. One example is Capistrano, which is often used for Ruby on Rails projects but can also be used to manage deployments for other types of applications and frameworks. Some research will certainly turn up other deployment tools that you may like better, but it's a reasonable place to start.
The easier solution to automatic deployments from a remote Git repo would most likely include using a deployment service.
Consider this setup:
Then, follow this general workflow:
Note: I hope you're not going to use automatic deployments for anything that can be considered critical, like your company website
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With