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

前端 未结 6 1394
臣服心动
臣服心动 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:30

    To erase your latest local commit use the following:

    git reset HEAD^
    

    This will get the header back to the state previous to the commit, and will allow you to git pull from master. Make sure you save all your changes elsewhere (locally) before pulling from the remote repository.

    To be able to pull without conflicts use git stash, and then git pull.

提交回复
热议问题