Git says local branch is ahead of remote after having pulled from remote

前端 未结 2 834
梦如初夏
梦如初夏 2021-02-18 23:02

I’m sorry if the title isn’t clear, but this is a weird problem.

I git checkout to my \"stage\" branch and git pull to get my partner’s latest

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-18 23:44

    I got the similar problem now after the following had happened:

    • My collegue pushed a simple commit
    • I pulled that commit, my tool has marked "Commit merged changed immediately"
    • My collegue decides to do an --amend to change his original commit so that it becomes two different commits instead
    • I pulled that changes, ending up being three commits ahead of origin

    My simple solution was to undo these three local commits, running the following command for each commit:

    git reset --soft HEAD~1
    

    Then git status tells I am behind origin with two commits, and I can pull those commits as usual.

提交回复
热议问题