Skip to content

Instantly share code, notes, and snippets.

@aqlx86
Created June 20, 2013 13:12
Show Gist options
  • Save aqlx86/5822529 to your computer and use it in GitHub Desktop.
Save aqlx86/5822529 to your computer and use it in GitHub Desktop.
git post-receive hook
#!/bin/bash
#
livepath="/path/to/your/live"
devpath="/path/to/your/dev"
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [[ "master" == "$branch" ]]; then
git --work-tree=$livepath checkout -f $branch
echo 'Changes pushed live.'
elif [[ "development" == "$branch" ]]; then
git --work-tree=$devpath checkout -f $branch
echo 'Changes pushed to dev.'
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment