Replacing Master Branch in Git

In a project managed by Git, there might be times that you need to completely trash the master branch and completely replace with another branch

Posted by Darwin Biler on October 3, 2015

In a project managed by Git, there might be times that you need to completely trash the master branch and completely replace with another branch.

lets say you have a “v2” branch. you can replace the master branch with the following steps

Checkout to the v2 branch

git checkout v2

merge it with the master branch with “ours” strategy.

git merge -s ours master

Checkout to the master branch

git checkout master

merge the v2 branch to master

git merge v2

The old master branch is now gone and the contents of the master is the contents of v2 branch.


Did you find this useful?

I'm always happy to help! You can show your support and appreciation by Buying me a coffee (I love coffee!).