Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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/
@zigotica

This comment has been minimized.

Copy link

@zigotica zigotica commented Oct 31, 2014

@benfrain thanx for the trick!
I improved it by making destination folder dynamic, see here: https://coderwall.com/p/qjmp1g

@snotrman

This comment has been minimized.

Copy link

@snotrman snotrman commented May 10, 2019

thank you for the script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.