"Your branch is ahead of..." in Git

The following commands seem like a bug to me, but I'm not a git genius so...

$ git status
# On branch master
nothing to commit, working directory clean

$ git pull origin master

 app/controllers/cool_controller.rb                   | 22 ++++++++++++++++++++--
 app/controllers/application_controller.rb            | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
 test/fixtures/interesting_model.yml                  |  2 +-
 test/fixtures/other_interesting_model.yml            | 10 +++++++++-

$ git status

# On branch master
# Your branch is ahead of 'origin/master' by 7 commits.
#   (use "git push" to publish your local commits)
#
nothing to commit, working directory clean

I disagree with git here, if I just pulled from master and I had no previous changes, how am I ahead of master?

And here is the other thing, if I do

git reset origin/master --hard

I lose the changes from the pull! So it seems like git is not updating the local origin/master when I pull. How can I fix this?

Thanks!


Try this:

git fetch

See git: Your branch is Ahead by X commits for more information about why this should work.

链接地址: http://www.djcxy.com/p/23158.html

上一篇: 如何清除“这个分支是N提交主人”?

下一篇: “你的分支在Git之前”