git: Why am I ahead of origin/master with X commits after I do 'git push'?
Asked Answered
R

3

9

I am using a bare git repository on a server for backup, and push local changes there with 'git push' after doing 'git commit' locally.

'git status' tells me

# On branch master
# Your branch is ahead of 'origin/master' by X commits.

If I modify a file, and then do another commit followed by a push, git tells me that my branch is ahead by X+1 commits. 'git remote show origin' shows me that both fetch and pull URLs are the same as I supply as argument to push.

I have verified that my changes do indeed get pushed to the server repository (by pulling into a different location and checking the contents).

What am I doing wrong here?

PS: I am aware that there are several related questions here on SO, but I could not find the answer to my specific issue in any of those. Please point me in the right direction if I'm wrong in that regard.

Raffinose answered 11/10, 2010 at 14:18 Comment(4)
I have no answer for you but I want you to know you're not alone! I sometimes see this message, and if I do a pull/push, even though nothing seems to be transferred, this goes away.Marable
have you tried to run 'git fetch origin' after pushing ? Maybe the remote branch doesn't get updated after the push.Tallbot
@François, indeed, same as for pushing, it's the reference name that matters (to get it updated).Calvert
@François is right. Do a 'git fetch origin' to update tracking info.Anacoluthon
C
6

It sounds like you're pushing to the URL directly. Try git push origin, this will update the references for origin (in principle, you can have the same URLs twice with the same reference name: the message refers to the reference name).

Calvert answered 11/10, 2010 at 14:23 Comment(1)
Thank you, that took care of it!Raffinose
S
1

Sometimes you'll run into this even though you actually don't have local commits. If you're stuck, and a

git pull origin [branch]

doesn't help you out, simply try

git pull origin and git pull

These commands should set your repo straight and clear up your issue of being ahead of origin/master by X commits.

Skewback answered 3/5, 2012 at 18:3 Comment(0)
A
0

I've found that updating your tracking information of "origin" works as well.

Try:

git fetch origin
Anacoluthon answered 13/3, 2014 at 17:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.