threads / discuss / 44588

"Your branch is ahead of 'origin' by X commits"

Subject: "Your branch is ahead of 'origin' by X commits"

## tl;dr

3 messages between Dec 1, 2016 and Dec 2, 2016.

replies: 2people: 3as markdown or json

Alfonsogonzalez, Ernesto (GE Digital)· Dec 1, 2016, 19:49 UTC · lore
Hi,

Git status tells me "Your branch is ahead of 'origin' by 108 commits.², but my local and origin/master are pointing to the same commit.

What am I doing wrong?
$ git diff origin/master
$ git status
On branch master
Your branch is ahead of 'origin' by 108 commits.
  (use "git push" to publish your local commits)
Untracked files:
  (use "git add <file>..." to include in what will be committed)

... nothing added to commit but untracked files present (use "git add" to track) $

$ git show origin/master --oneline 92d392c Merge pull request #21 from org/branch

$ git show master --oneline 92d392c Merge pull request #21 from org/branch

$ git --version git version 2.10.2

Thanks,
Ernesto
Jeff King· Dec 1, 2016, 21:47 UTC · re: Alfonsogonzalez, Ernesto (GE Digital) · lore

Re: "Your branch is ahead of 'origin' by X commits"

On Thu, Dec 01, 2016 at 07:49:40PM +0000, Alfonsogonzalez, Ernesto (GE Digital) wrote:
Show 7 quoted lines
> $ git diff origin/master
> $ git status
> On branch master
> Your branch is ahead of 'origin' by 108 commits.
>   (use "git push" to publish your local commits)
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)

The "master" we are talking about here must always be "refs/heads/master", since it will have come from resolving the HEAD symbolic ref.

But here:
Show 5 quoted lines
> $ git show origin/master --oneline
> 92d392c Merge pull request #21 from org/branch
> 
> $ git show master --oneline
> 92d392c Merge pull request #21 from org/branch

The "master" in the second case could possibly find "master" as another name. Is it possible you have a .git/master file (this may have been created by accidentally running "git update-ref master" instead of "git update-ref refs/heads/master")?

Or other things you could check:
  # see what's on HEAD, which we know points to refs/heads/master
  git show HEAD
  # or just check refs/heads/master itself
  git show refs/heads/master
  # or just ask what "master" resolves to
  git rev-parse --symbolic-full-name master

That last one actually seems to complain that "refname 'master' is ambiguous' if you do have .git/master. I think that's a minor bug, as it should presumably follow the normal disambiguation rules used for lookup (in which .git/master always takes precedence over refs/heads/master).

-Peff
Matthieu Moy· Dec 2, 2016, 13:42 UTC · re: Alfonsogonzalez, Ernesto (GE Digital) · lore

Re: "Your branch is ahead of 'origin' by X commits"

"Alfonsogonzalez, Ernesto (GE Digital)" <ernesto.alfonsogonzalez@ge.com> writes:

Show 11 quoted lines
> Hi,
>
> Git status tells me "Your branch is ahead of 'origin' by 108 commits.²,
> but my local and origin/master are pointing to the same commit.
>
> What am I doing wrong?
>
> $ git diff origin/master
> $ git status
> On branch master
> Your branch is ahead of 'origin' by 108 commits.

This line should say "ahead of 'origin/master'" in common setups, where 'origin/master' is the remote-tracking branch configured as upstream for 'master'.

My guess is that you have a badly configured upstream.

What does "git pull -v" say? What's the content of the [branch "master"] section of .git/config?

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

← back to recent threads