Skip to content

Instantly share code, notes, and snippets.

@a7madgamal
Last active May 17, 2016 20:04
Show Gist options
  • Save a7madgamal/00f40d6b248991abf116cff916e5a52c to your computer and use it in GitHub Desktop.
Save a7madgamal/00f40d6b248991abf116cff916e5a52c to your computer and use it in GitHub Desktop.
#create hook script: /path/to/git/bare/repo/post-receive
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "pulling master"
git --work-tree=/path/to/working/dir --git-dir=/path/to/working/dir/.git pull origin master
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
# then run this to make it executable
chmod +x post-receive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment