George Garside Blog

A place of many ramblings about macOS and development. If you find something useful on here, it's probably an accident. • See all at

The common git log command is one of the first learned, rightfully so. However, when first navigating around a repository history, the default format output of the log is quite verbose. Two options I like to use, especially together, are

  • --oneline, compressing each commit into one line, and
  • --graph, drawing an ASCII diagram of the commits hierarchy in the tree.

The default line format of --oneline is

* abcd123 (HEAD, dev/foo) Add foo
^ graph position          ^ commit message
  ^ commit sha   ^ branch name
           ^ HEAD pointer

The graph position asterisk shows where the commit falls on the graph drawn on the left of the commits. Here are some examples of graphs of commits as presented by git log --oneline --graph:

* (HEAD) C
* B
* A

Simple graph of three commits, with a detached head at C.

* C
| * D
* B
* A

New commit D branched off at B.

* (HEAD) E
| * (master) D
* | C
* B

Reverse merging master into a feature branch causing a mess. Don't do this, rebase on master instead.

Leave a Reply

No comments