Last Updated: February 25, 2016
·
206
· purwa-astawa

Auto Git Deployment

from this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps

#!/bin/bash
DIRNAME=$1

##make git dir and working dir
mkdir /var/repo/$DIRNAME.git 
mkdir /var/www/$DIRNAME

#cd into git folder
cd /var/repo/$DIRNAME.git

#now we are in git repo, lets init bare repository
git init --bare

#go to hooks folder and create post-receive file
cd hooks

##create post-receive file
printf "%b\n" "#!/bin/bash" "git --work-tree=/var/www/$DIRNAME --git-dir=/var/repo/$DIRNAME.git checkout -f" > post-receive

chmod +x post-receive