Imagine a situation where you have two branches of the same project, with one part of the first branch dramatically refactored over the other one. But for a while you need to keep both branches functional, so you are doing bug fixes and crucial feature additions to both of them, sometimes in a not symmetrical way. And at some point there comes a moment when you have to merge refactored branch onto the original one. What is the best technique to use in a situation like this? Is it still possible to keep the history clean?
But more importantly what should have been my initial strategy in such scenario?
Since the task was to simply use another branch instead of
master, you can simply removemasterbranch completely or rename it to let’s say –legacy, then take another branch and rename it tomaster. That’s it. Here are actual commands that you might need to execute to achieve the goal locally and on GitHub:Locally we are done now. However you cannot simply remove
masterbranch on GitHub. You need to take another branch as default first. This can be done in repositorySettings > Default Branch. Once you do this, you can proceed:Then go back to
Settings > Default Branchand switch default branch back tomaster. Additionally you can remove all extra branches that you might have created during migration process.Alternatively, if you are looking to save all your actions in history, check a correct answer here.