1

In the project I'm working on right now I have just submitted a merge request that has been merged into master on origin (our gitlab server). After that I made a single commit to fix a typo, and manually merged my branch into master locally (please don't kill me).

I'm now puzzled by the message I get when I run git status:

On branch master
Your branch is ahead of 'origin/master' by 15 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Because as far as I understand my local master branch is only 3 commits ahead. This is the (slightly modified) output of git log -n5:

commit cdbbbfdaf55deef575914f2cbf8cfec549479973 (HEAD -> master)
Merge: bc1a6b9 a32002a
Author: Developer 1 (me)
Date:   Wed Jan 4 11:03:45 2023 +0100

    Merge into master

commit a32002a75a559943968d8694287dc16b1297e1cf (development-branch)
Author: Developer 1 (me)
Date:   Wed Jan 4 11:02:36 2023 +0100

    Fixed typo

commit bc1a6b9ba9b56063044730fb20cc5f1b43194dea (origin/master, origin/HEAD)
Merge: 91f3302 eabfd24
Author: Developer 2
Date:   Wed Jan 4 09:33:41 2023 +0000

    Merge branch 'development-branch' into 'master'
    
    Development branch
    
    See merge request Repository!7

commit eabfd244f4791b66cf4c26a9fb574c9317279021
Author: Developer 1 (me)
Date:   Wed Jan 4 09:33:41 2023 +0000

    Development branch

commit 9eb2390feec6650a446bff4e9309bd29c7ed18e8 (origin/development-branch)
Merge: 2517a68 91f3302
Author: Developer 1 (me)
Date:   Wed Jan 4 10:26:37 2023 +0100

    Merge

A git pull says everything is up to date. Why this discrepancy?


Edit

As @florieger points out, the output of git log origin/master..master shows 15 commits, the first three of which are:

commit cdbbbfdaf55deef575914f2cbf8cfec549479973 (HEAD -> master)
Merge: bc1a6b9 a32002a
Author: Developer 1 (me)
Date:   Wed Jan 4 11:03:45 2023 +0100

    Merge into master

commit a32002a75a559943968d8694287dc16b1297e1cf (development-branch)
Author: Developer 1 (me)
Date:   Wed Jan 4 11:02:36 2023 +0100

    Fixed typo

commit 9eb2390feec6650a446bff4e9309bd29c7ed18e8 (origin/development-branch)
Merge: 2517a68 91f3302
Author: Developer 1 (me)
Date:   Wed Jan 4 10:26:37 2023 +0100

    Merge

(12 additional commits not shown)

i.e. commits 1, 2 and 5 in git log -n5. But why is the merge (bc1a6) not visible here? The output of git log -n5 seems to me to suggest that origin/master points to this ref, so why are they different?

glaux
  • 701
  • 7
  • 20
  • "Merge branch .... into master" sounds like it merged several commits into master (possibly 12 commits?). `git pull` will not do anything if your local clone is _ahead_ (only if you are behind or diverged) – knittl Jan 04 '23 at 12:06

1 Answers1

0
  1. Make sure you are on the master branch locally.
  2. run git log origin/master..master

It should list you all 15 commits between origin/master and local master branch.

florieger
  • 1,310
  • 12
  • 22
  • Ok, that does show 15 commits. But I don't understand why? I've updated the question. – glaux Jan 04 '23 at 12:49
  • @glaux. Maybe `development-branch` has a problem of root. For this branch the common ancestor commit with origin/master is older than you think. Maybe you have a forgotten `git pull` in your `development-branch`. Try to restart. Perhaps my answer could help you there : https://stackoverflow.com/a/60237501/10489562 – phili_b Jan 04 '23 at 13:03