Do git pull on push event to a repo
- Install git cli tools on your server, eg.
sudo apt-get install git
for ubuntu - Upload
git.sh
,onetime.sh
,git.php
to your server web directory or any web directory you want to sync, eg./var/www/html
for apache. - set owner of all the files to user which run the server (eg.
www-data
for apache) and set file permission to 750! - Run
onetime.sh #{https git url}
from shell once as superuser - Set webhook in your repo for push event to
git.php
location - You are done, now everytime there is a push event on your repo, server will automatically pull from your repo.
- You can add other commands in git.sh file which you would like to execute after pulling, like starting a server etc.