git: Your branch and 'origin/master' have diverged - how to throw away local commits?

前端 未结 6 1393
臣服心动
臣服心动 2020-12-22 17:07

I have the following message in git:

# Your branch and \'origin/master\' have diverged,
# and have 3 and 8 different commits each, respectively.
#   (use \"         


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-22 17:31

    If a hard reset doesn't cut it for you and you don't want to do a pull-merge you can throw away your local unwanted changes by deleting your local branch and re-download the origin one:

    git branch -D 
    git checkout -b  origin/
    

    Using master as an example:

    git branch -D master
    git checkout -b master origin/master
    

提交回复
热议问题