Mike Griffin

Moving Another Branch to Master on Github

I’ve been rewriting my other site over the last few months and I was using a different branch to develop on. It has finally come to the time where I’m happy to release it.

But I ran into a problem, because it has changed so radically, it has veered a long way away from the master branch that was originally there. To fix this I wanted to rename the master branch to something else and move the develop branch to be the new master.

After some searching, I found a site that had instructions on how to do it. It’s a nice simple process and it worked out very easily. I’m going to repeat it here in case the other page ever disappears.

  • On Github, set the default branch to something other than master
  • Rename the local branches
git branch -m master legacy
git branch -m dev master
  • Delete the master branch on Github
git push origin :master
  • Push up the new master to Github
git push origin master:refs/heads/master
  • Push up the legacy code to Github
git push origin legacy:refs/heads/legacy
  • Delete the old branch on Github
git push origin :dev

That’s it, there is now a new master and the old master is in a branch called legacy.