Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
Forked from benfrain/post-receive.sh
Created July 3, 2019 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IgorDePaula/794ee4649aaa7429382c9a190834c5c5 to your computer and use it in GitHub Desktop.
Save IgorDePaula/794ee4649aaa7429382c9a190834c5c5 to your computer and use it in GitHub Desktop.
post-receive hook for multiple branches
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi
if [ "dev" == "$branch" ]; then
git --work-tree=./path/under/root/dir/dev-site/ checkout -f $branch
echo 'Changes pushed to dev.'
fi
done
# Taken from: http://blog.ekynoxe.com/2011/10/22/git-post-receive-for-multiple-remote-branches-and-work-trees/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment