← go back

git tricks: Logs

Published on 19 Jul 2026

This post is copied from my page on Floppy.

Updated on 19 August: Today I learned about --reflog switch. No more subshell madness.

One might think of git as a forest, and in forests there are usually a lot of logs. Git, on the other hand, only has three of them: log, shortlog, and reflog.

the short one

Did you know Git can summarize commit ranges for you? Try it out with git shortlog HEAD~10.. and it'll give you a nice and quick summary. As a bonus, it doesn't even defer to an LLM, which is a massive win.

git-shortlog is a postprocessor for the "main" log output, leaving only summary lines from the commits and grouping by author (other options are available, with grouping by committer having its own short option, -c).

the ref one

Reflogs are used when commits are mentioned with @{N} suffix, where N denotes the position of the entry in the reflog, relative to the most recent one. The most important of reflogs is of course the HEAD reflog, which allows using HEAD@{N} references and holds the history of HEAD, including all rebase steps and dropped and amended commits. For example, one can use HEAD@{1} after fast-forward-merge to refer to the previous HEAD.

Note that reflogs are appended to, and checkouting to HEAD@{N} will append new entries to the reflog, so the backreference numbers are offset by one.

It is possible to manipulate the reflog manually with subcommands:

The write subcommand might be useful for custom git-based tooling.

Stash stack is implemented using refs/stash reflog.

The reflog is also accessible with git log --walk-reflogs HEAD.

the main one

git log is the "main" log. It is probably The Log people will think of when you mention git log, and it holds commit graph. This graph is sometimes called "commit history" or simply "history".

git log command has dozens of options. Some of them might even seem useful.

Decision paralysis time! Here's a filtered list of cool options:

I have the following aliases:

l = "log --topo-order --graph --decorate --format=format:\"...\""
ll = "!git l --all"
lr = "!git ll --reflog"
lo = "!git l --oneline"
llo = "!git ll --oneline"
lro = "!git lr --oneline"

The --format=format:"..." bit is the only uncovered one. There is a lot of formatting options, and Git gives a lot of freedom in terms of styling. If you have some spare time, try tweaking the format to your pleasure. Format string I use is a middle-ground between --oneline and default format, and it shows commit id, author, date, relative date and subject (with spaces converted to line breaks for readability):

%C(bold blue)%h%C(reset)
%C(dim italic cyan)%aD%C(reset)
%C(dim white)%aN%C(reset)
%C(green)(%ar)%C(reset)%C(yellow)%d%C(reset)%n
%C(white)%s%C(reset)

I don't use it that often, as I have come to realise that I don't usually need that many information on my screen, and --oneline has a good everyday balance for me.

Be careful with formatting strings, as some options don't respect .mailmap files. Use %aN, %aE, %aL, %cN, %cE, %cL instead of the ones with the lowercase n, e, and l to avoid seeing outdated information.


  1. This previously mentioned using $(git rev-list -g --all). Git supports --reflog option since version 2.2, released in 2015, and that option is equivalent to the subshell snippet, while lacking its obvious limitation of kernel argument length limit. ↩︎