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

前端 未结 2 835
梦如初夏
梦如初夏 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.

    0 讨论(0)
  • 2021-02-18 23:59

    Try this command:

    git log origin/stage..stage
    

    This show you what you are ahead of the remote. Do a git rebase origin/stage / git push as appropriate.

    If it doesn't help, see this question : 'git pull origin mybranch' leaves local mybranch N commits ahead of origin. Why?

    0 讨论(0)
提交回复
热议问题