Skip to content

Instantly share code, notes, and snippets.

@ozh
Created November 27, 2012 15:41
Show Gist options
  • Save ozh/4154909 to your computer and use it in GitHub Desktop.
Save ozh/4154909 to your computer and use it in GitHub Desktop.
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:

#!/bin/sh
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