Useful Git Commands: Summarizing Lots of Log Entries

2 Apr 2014

When looking for a summary of a git repository’s history, the output of git log isn’t always as informative as one might like. It displays every commit in chronological order, which effectively hides the changes that merges bring in. It is also quite verbose, showing complete log messages, author info, commit hashes, and so on, drowning us with so much info that only a few commits will fit on the screen at once. After supplying the command with the right cocktail of options, though, its output becomes a significantly better summary:

Output of ``git graph''

The output above came from a command that is long enough that I made an alias, for it, git graph, in my ~/.gitconfig file:

[alias]
    graph = log --graph --abbrev-commit --date=relative --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(blue)<%an>%Creset'

Don’t forget that git log accepts a list of things to show logs for as well, so if you want to look at the logs for branch-1 and branch-2 you can simply use git graph branch-1 branch-2 to make them both show up in the graph.