gitcommitgit-branchgit-history-graph

Git: how this bifurcation happen?


Situation

enter image description here

Questions

As I mentioned nothing points to it and I did a git -gc to clean up any hanging commit.


Solution

  • There is no tag nor any other [commit] pointing to c79dc19

    That's not what the history shows.

    Try running git show HEAD - it'll show what the two parents of the merge are. It looks from your graph like one is the c79dc19, and that's why it shows up in your history.

    Most likely, either the branch really started at c79dc19 (so that was already on master), or the branch was merged to master as a fast-forward when c79dc19 was its head.


    Worked illustration:

    1. initial state

      fe62 <=master <=HEAD
      
    2. new commit

      fe62 <- c79d <=master <=HEAD
      
    3. checkout new branch

      fe62 <- c79d <=master <=branch <=HEAD
      
    4. amend (on branch) gives a new commit 0c81 which replaces c79d on that branch but doesn't change master

      fe62 <- c79d <=master
           \- 0c81 <=branch <=HEAD