Enhanced Git Log View Showing Symbolic References Associated With Each Commit

With multiple upstream repositories and branches, and different branches on different upstreams, an enhanced “log” view will help greatly in taking stock of everything. Adding the following line to your “~/.gitconfig” will give you a new command, “git slog” (for “short log”) that does just that: < p>

    # colorful 1-line log summary
    slog = log --pretty=format:'%Creset%C(red bold)[%ad] %C(blue bold)%h %Creset%C(magenta bold)%d %Creset%s %C(green bold)(%an)%Creset' --abbrev-commit --date=short

This command will provide a colorful one-line summary of the project’s commit history, showing not only the commit date, SHA-1, commit message and author, but, most importantly in this context, an indication of the symbolic references associated with various commits in nice, bright [magenta]. So, for example, in this log we can see:

  • ”(HEAD, master)“, telling us that our current local HEAD and the tip of the local “master” branch are both on commit d685fb3.
  • ”(origin/master, origin/HEAD)“, telling us that the HEAD of the remote origin is two commits behind us, as is the tip of its “master” branch.
  • ”(fasta-tweak)“, telling us that we have a local branch, “fasta-tweak”, with its tip at revision 1f87947.
  • ”(dev/master)“, telling us that the tip of the “master” branch is way behind everything else, on revision f070902a.
  • Various “(tag: ###)” entries, showing us the commits pointed to by various tags.

With a log summary such as this, managing multiple branches across multiple repositories is greatly facilitated.

Share