gitgithubrebasegit-forkupstream-branch

Restore master from upstream repo into fork


I accidentally deleted the master branch from my fork. Now I want to reset master in my fork to be as the upstream master.

How do I do this?


Solution

  • You can create a new master branch by tracking upstream master branch and force push the newly created master branch to you forked repo. The command would be like below,

    $ git fetch upstream
    $ git checkout -b master --track upstream/master
    $ git push <forked-repo-origin> master -f
    

    Please try it out and let me know if you need more.