GIT — graph

Lately I’ve started to gravitate from GIT GUI’s tools to CLI.
What I missed was graphical representation of development of ehm… development.
However as with most popular open source tools , there’s solution for almost everything.

Simple

Just type in following command and enjoy. Well there are few downsides but it’s simple.

git log --graph -all

Most apparent downsides for some of us might be paging (git won’t finish / continue without user input in one go) and each commit taking multiple lines making even small three taking up multiple pages worth of lines.

Most options

if you prefer perfectly customized output you can in fact create formatted output by going all the way of adjusting all multiple little details.

git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all

output

Obviously it’s not for free and you might end up with pretty long command line. You can however write it only once and then save it under global alias.

Best of both worlds

And at least solution which doesn’t need 4 full lines of code but also delivers quite attractive result. Best thing is, it can be modyfied

git log --pretty=format:"%h %cr %s" --graph --all

–pretty=format:”…” basically let’s you define table next to the “graphical” three.

SpecifierDescription of Output
%HCommit hash
%hAbbreviated commit hash
%TTree hash
%tAbbreviated tree hash
%PParent hashes
%pAbbreviated parent hashes
%anAuthor name
%aeAuthor email
%adAuthor date (format respects the --date=option)
%arAuthor date, relative
%cnCommitter name
%ceCommitter email
%cdCommitter date
%crCommitter date, relative
%sSubject
Source: https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History

Output

As you can see. You get quite pleasing output with minimal code.

en_USEnglish