Master branch is "Already up-to-date", and yet it is "ahead of origin/master by 4 commits"?

573 Views Asked by At

I understand that if I have commits on my local master branch that are not in the remote master branch, then I can get "Your branch is ahead of origin/master by X commits".

But, after I git pull origin master, I see the message "Already up-to-date". So, I thought that means exactly that: none of my commits are ahead/behind master.

But when I do git status still am receiving this message "Your branch is ahead of origin/master by X commits". Even when I do git pull -f origin master I'm still getting this message!! How is that possible when I'm "Already up-to-date"?

I understand questions like this, but they still don't tell me why the "up-to-date" means "ahead"?

1

There are 1 best solutions below

3
On BEST ANSWER

Let’s illustrate by below graphs:

Assume this is the remote master branch,

A---B---C origin/master

And this is your local master branch, you make X commits on local,

A---B---C---D---E---…---N master

So when you want to pull remote master branch(commit A,B and C) to local which already exist in local commits, so git will show already up-to-date message for you. And this is consistent with git status’ messge Your branch is ahead of origin/master by X commits.