why does it say “Your branch is ahead of origin/master by 857 commits” when I need to *pull* origin master

后端 未结 5 1131
予麋鹿
予麋鹿 2020-12-24 14:16

Firstly, I\'m aware of a number of similarly worded questions, eg:

  • How can I find the location of origin/master in git, and how do I change it?
  • git:
5条回答
  •  爱一瞬间的悲伤
    2020-12-24 14:39

    I had the same issue. Like the chosen solution points out, I think the problem was the origin/master pointer being out-of-date. I mostly only do git pull origin master and not fetch.

    Since I know I didn't have local changes, I hard reset to master and then fetched to update the pointer, and finally pulled to catch up on the commits on the remote master branch. Like this:

    git reset --hard origin/master
    git fetch origin
    git pull origin master
    

    Hope this helps someone in the future too.

    Edit: also useful On this other question, I found a great solution with useful commands. These worked for me when the above didn't!

    If you get this message after doing a git pull remote branch, try following it up with a git fetch. (Optionally, run git fetch -p to prune deleted branches from the repo)

    Fetch seems to update the local representation of the remote branch, which doesn't necessarily happen when you do a git pull remote branch.

提交回复
热议问题