How to read a Git log graph
Asked Answered
C

2

117

In the Git community book, it says

Another interesting thing you can do is visualize the commit graph with the '--graph' option, like so:

$ git log --pretty=format:'%h : %s' --graph
* 2d3acf9 : ignore errors from SIGCHLD on trap
*   5e3ee11 : Merge branch 'master' of git://github.com/dustin/grit
|\
| * 420eac9 : Added a method for getting the current branch.
* | 30e367c : timeout code and tests
* | 5a09431 : add timeout protection to grit
* | e1193f8 : support for heads with slashes in them
|/
* d6016bc : require time for xmlschema

It will give a pretty nice ASCII representation of the commit history lines.

How should I read this graph? How does 420eac9 differ from the rest?

Confinement answered 21/3, 2011 at 18:55 Comment(0)
G
150

The asterisks show where something was committed:

e1193f8, 5a09431 and 30e367c were committed to the left branch (yielding a | on the right branch) whereas 420eac9 was committed to the right branch (yielding a | on the left branch). And that is how 420eac9 differs from the rest: it's the only commit to the right branch.

For the sake of completeness:

  • d6016bc was the branching point
  • 5e3ee11 is the merging commit
  • 2d3acf9 is the first commit after merging
Glossectomy answered 21/3, 2011 at 19:43 Comment(7)
I had a question about commit times as shown in the graph. In the graph, '420eac9' is shown above '30e367c', '5a09431', and 'e1193f8'. Would that always mean that '420eac9' was committed after the other three, or is it that commits on a branch are grouped together, and the order in which they appear across branches, does not have a time correlation ?Ringer
@Parag: commits in a branch are grouped together. 420eac9was done after the first commit of the e1193f8 branch but not neccessarily after 30e367cGlossectomy
@Glossectomy so are the | symbols on the left (the most left) a representation of the branch that I'm currently on?Binghi
@Binghi if you switch to another branch and run the same command, you get the same output, so there's no reference in the graph to the current branch you are onAzevedo
Where is this documented?Pasco
@young_souvlaki here, at StackOverflow?Glossectomy
@Glossectomy link the source.Pasco
B
23

420eac9 is on a different branch than the 3 commits "below" it. The branches diverged after d6016bc and they were merged in 5e3ee11.

Barney answered 21/3, 2011 at 18:58 Comment(1)
Maybe a better wording than the branches diverging is that a second branch was created from d6016bc and developed in parallel with the original branch.Barney

© 2022 - 2024 — McMap. All rights reserved.