Last active
December 16, 2015 22:09
-
-
Save benklocek/5505392 to your computer and use it in GitHub Desktop.
Git Hub repo post-update hook to update based on branch pushed. modified from http://blog.ekynoxe.com/2011/10/22/git-post-receive-for-multiple-remote-branches-and-work-trees/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# post-update hook for Hub git repo | |
# http://stackoverflow.com/questions/5753346/git-automatically-push-to-dev-and-production-from-central-repository-depending-o?rq=1 | |
# post-update only receives refname | |
# TODO: adjust for post-update ref, and cd to Prime and pull | |
# | |
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