Clean up a fork and restart it from the upstream

后端 未结 4 885
南笙
南笙 2020-11-29 14:04

I have forked a repository, then I made some changes and it looks like I\'ve messed up everything.

I wish to start it again from scratch, using the current upstrea

4条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 14:42

    Following @VonC great answer. Your GitHub company policy might not allow 'force push' on master.

    remote: error: GH003: Sorry, force-pushing to master is not allowed.

    If you get an error message like this one please try the following steps.

    To effectively reset your fork you need to follow these steps :

    git checkout master
    git reset --hard upstream/master
    git checkout -b tmp_master
    git push origin
    

    Open your fork on GitHub, in "Settings -> Branches -> Default branch" choose 'new_master' as the new default branch. Now you can force push on the 'master' branch :

    git checkout master
    git push --force origin
    

    Then you must set back 'master' as the default branch in the GitHub settings. To delete 'tmp_master' :

    git push origin --delete tmp_master
    git branch -D tmp_master
    

    Other answers warning about lossing your change still apply, be carreful.

提交回复
热议问题