GIT Replace Branch With Another - gecko-8/devwiki GitHub Wiki

Up

Note: in the following instructions we'll refer to the original main/master branch as and the branch we want to replace it with as .

  1. Switch to the new main branch
    git checkout <new main>
  2. Merge the original main branch into the new main branch
    IMPORTANT: The "-s ours" switch makes sure we only use changes from the new main branch
    git merge -s ours master
  3. Switch to the original main branch
    git checkout <original main>
  4. Merge the new main branch into the existing one
    git merge <new main>
  5. The main branch will now match the new one
⚠️ **GitHub.com Fallback** ⚠️