0

Is it possible to setup a branch that will always contain what a different branch contains? I ask because I have a project using GitHub where I want the pg-pages branch to always contain what is in master. Thanks.

Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232

1 Answers1

2

This sounds like you are missing a point here. Branch names are nothing special in git – if you want the pg-pages branch to be the main branch, just use it as your main branch and delete master.

If you are convinced being forced to use that name is to much of an inconvenience so it’s worth the trouble, you can solve that in other ways:

  • Use this command for pushing master (or add it as an alias):

    git push origin master master:gh-pages
    
  • Add a post-commit hook, that checks if you just commited on master (by checking whether it’s the current branch / whether HEAD points to it) and if you did, runs this command:

    git branch -f gh-pages master
    

    note that you will still have to push gh-pages afterwards.

Chronial
  • 66,706
  • 14
  • 93
  • 99