Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Git trick: have a branch mirror another one

Git post-commit hook to keep master and gh-pages branch in sync :

In your Git repository create a file .git/hooks/post-commit and fill it with this:

git checkout gh-pages
git rebase master
git checkout master

After that every commit that you do on the master branch will immediately also be applied to the gh-pages branch. When pushing to Github simply use git push --all instead of git push origin master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment