A little while ago I started to re-write one of my gems, however, because it was such a drastic re-write, development was done in a brand new branch. So no code existed on this new branch. Finally came to the point where I decided to switch the old gem out for the new one on GitHub, and instantly ran into problems. I couldn't really just merge the development branch into master, as it wasn't originally based off master, so this is what I did...
- On the GitHub repo, set the default branch to be the 'dev' branch.
-
Rename the local branches
git branch -m master legacy git branch -m dev master -
Delete the remote 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 old legacy code to GitHub.
git push origin legacy:refs/heads/legacy - On the GitHub repo, change the default branch back to 'master'
-
Finally, Delete the old remote dev branch on GitHub.
git push origin :dev
So now you should have the old master branch in a new branch called 'legacy' and the new 'dev' branch as master. Done and done!
