How do I reset the git master branch to the upstream branch in a forked repository?

后端 未结 4 2087
轮回少年
轮回少年 2020-12-22 16:24

I\'ve completely messed up the master branch of my forked git repo.

I want to completely reset the master branch that was pushed to my fork with the contents of the

4条回答
  •  余生分开走
    2020-12-22 16:51

    This would reset your master branch with the upstream master and if the branch has been updated since your forked it would pull those changes as well.

    git checkout master 
    git reset upstream/master
    git pull --rebase upstream master
    git push origin master --force
    

    PS: Assuming Upstream is the original repo while origin is your copy.

提交回复
热议问题