Search code examples
gitgithubgit-mergegit-branch

Make my github master branch match another branch


I've been working on a forked branch "forkedBranch" and made many updates to my app. When I was happy with the updates, I went back to my master branch (git checkout master) and merged my forkedBranch (git merge forkedBranch). Unfortunately, the master branch has lots of problems with it that weren't present in forkedBranch.

The app is too complicated for me to want to go through and find all the bugs. Is there a way to make my master branch identical to forkedBranch to save me the hassle?


Solution

  • If you're absolutely certain you don't need the master branch or any of its old commits:

    1. git branch --delete master && git push origin -delete master - delete the master branch locally and on origin
    2. git checkout forkedBranch && git pull origin forkedBranch - pull down the latest forkedBranch from origin
    3. git checkout -b master && git push origin master - recreate the master branch locally from the latest commit of forkedBranch, and push it up to origin