Last active
August 29, 2015 14:15
-
-
Save kleinschmidt/72dfaa9e0c87bf68724c to your computer and use it in GitHub Desktop.
A pre-push hook to automatically publish to github pages every time you push.
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 | |
# drop this in .git/hooks/, and chmod +x .git/hooks/pre-push | |
# store current branch | |
cur_branch=$(git rev-parse --abbrev-ref HEAD) | |
if [[ $cur_branch == "gh-pages" ]] | |
then | |
# bail out if we're trying to push the gh-pages branch (to prevent infinite loop) | |
exit 0 | |
else | |
# merge current branch into gh-pages | |
git checkout gh-pages | |
git merge -m 'automatic pre-push merge' $cur_branch | |
# push gh-pages | |
git push origin gh-pages | |
# switch back and exit | |
git checkout $cur_branch | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment