git branch is ahead of origin/master while repo is in sync
git, github
Solution
I have experienced exactly what you see. I can't find the proper explanation on git-scm.com but I believe it to be something like this:
- I clone a repo from origin, lets say origin has master and I have master now in my local repo
- now origin and your repo have a reference to the last commit. This reference is the master branch AND the reference is the same in your local repo and on origin
- Let's say someone (other then you) pushes new commits to origin master
- you do `git pull origin master`
- now you do `git status` and you will see that your branch is ahead to origin/master even tough you have no new commits in your local repo and nothing to push!! (in this example, you did not commit anything new locally since step 1 (the cloning))
==> I fix this by doing a `git pull origin` when I'm on master.
A `git pull origin master` will pull all new commits from a branch on origin to your local branch.
A `git pull origin` will also re-set your reference to master equal to the commit where master is referenced on origin!! (When this didn't happen, the git-bash will just think that you are alot of commits ahead! because in the commit-tree there are alot of commits made after the commit where your master-reference is!)
Does this make any sence to you? It does to me :)
Also please feel free to support my toughts a bit with hard evidence/documentation :)
Problem
Folks, This is something in git that just does not make sense to me, here is what happens - I do a `git status`, I see that I am on branch master and nothing to commit and working directory is clean. - I then do `git pull origin master` I pull a bunch of code, no issues. - Now when I do `git status` I see a new line Your branch is ahead of origin/master by 1 commit My local repo and remote repo are totally in sync, what does your branch is ahead of origin/master by 1 commit mean, this is very very confusing.