115

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
michael
  • 106,540
  • 116
  • 246
  • 346

2 Answers2

149

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
young_souvlaki
  • 1,886
  • 4
  • 24
  • 28
eckes
  • 64,417
  • 29
  • 168
  • 201
  • 4
    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 ? – Parag Jan 08 '14 at 05:32
  • 6
    @Parag: commits in a branch are grouped together. `420eac9`was done after the first commit of the `e1193f8` branch but not neccessarily after `30e367c` – eckes Jan 08 '14 at 07:22
  • 1
    @eckes so are the `|` symbols on the left (the most left) a representation of the branch that I'm currently on? – J86 May 12 '20 at 08:51
  • @J86 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 on – onofricamila Jul 23 '20 at 13:41
  • Where is this documented? – young_souvlaki Mar 19 '21 at 19:17
  • @young_souvlaki here, at StackOverflow? – eckes Mar 20 '21 at 20:05
  • @eckes link the source. – young_souvlaki Mar 21 '21 at 15:19
22

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

Ilkka
  • 2,644
  • 1
  • 23
  • 27
  • 6
    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. – Ilkka Mar 21 '11 at 19:00