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

3 messages from 2016-12-01 to 2016-12-02. Participants: Alfonsogonzalez, Ernesto (GE Digital), Jeff King, Matthieu Moy.
Thread: https://gitlist.dev/t/44588

## Alfonsogonzalez, Ernesto (GE Digital), 2016-12-01 19:49

Subject: "Your branch is ahead of 'origin' by X commits"
Message-ID: <D465BDE6.B7DE%ernesto.alfonsogonzalez@ge.com>
URL: https://gitlist.dev/e/D465BDE6.B7DE%25ernesto.alfonsogonzalez%40ge.com

```
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, 2016-12-01 21:47

Subject: Re: "Your branch is ahead of 'origin' by X commits"
Message-ID: <20161201214750.awin75rfums6mjrv@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20161201214750.awin75rfums6mjrv%40sigill.intra.peff.net
In-Reply-To: <D465BDE6.B7DE%ernesto.alfonsogonzalez@ge.com>

```
On Thu, Dec 01, 2016 at 07:49:40PM +0000, Alfonsogonzalez, Ernesto (GE Digital) wrote:

> $ 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:

> $ 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, 2016-12-02 13:42

Subject: Re: "Your branch is ahead of 'origin' by X commits"
Message-ID: <vpqk2bisb0z.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpqk2bisb0z.fsf%40anie.imag.fr
In-Reply-To: <D465BDE6.B7DE%ernesto.alfonsogonzalez@ge.com>

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

> 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/

```
