Command line replacement for gitk --all and GitX

‹ Creating a one dimensional plot in R and ggplot2 | Firefox is already running, but is not responding ›

gitk --all, tig and GitX are invaluable for visualizing the git commit graph, but when GitX recently stopped displaying branch names on a repository I work with, I started looking for a stock git install command line replacement for two reasons:

  • It takes slightly longer to copy and paste GUI output over chat.
  • When helping someone with a git issue, it's time consuming to ask them to install GitX or gitk first.

Here is a command line that provides similar commit graph visualization:

git log --graph --date=short --pretty=format:'%C(auto)%h %d %s (%Cgreen%an%Creset) %Cblue%ad%Creset' --all

It produces output like this:

*   3812e68  (HEAD, origin/master, origin/HEAD, master) Merge "kill HAVE_PTHREADS." (Yabin Cui) 2015-01-27
|\  
| * 1610486  kill HAVE_PTHREADS. (Yabin Cui) 2015-01-26
|/  
*   82a1a2c  Merge "Add missing <string.h> includes." (Elliott Hughes) 2015-01-25
|\  
| * 35af2c3  Add missing <string.h> includes. (Elliott Hughes) 2015-01-25
* |   fe24754  Merge "Remove superfluous OpenSSL include paths." (Narayan Kamath) 2015-01-23
|\ \  
| * | 0e7829e  Remove superfluous OpenSSL include paths. (Adam Langley) 2015-01-22
|/ /  
* |   231df77  Merge "Fix default compute thread priority" (Jason Sams) 2015-01-22
|\ \  
| * | c9870c1  Fix default compute thread priority (Jason Sams) 2015-01-21
| |/  
* |   081cda8  Merge "Add FP16 types to the list of RenderScript types." (Jason Sams) 2015-01-22
|\ \  
| * | a5835a2  Add FP16 types to the list of RenderScript types. (Jason Sams) 2014-11-05
| |/  
* |   dca2332  Merge "Add support for persist.sys.locale." (Narayan Kamath) 2015-01-22
|\ \  
| * | d30dbb8  Add support for persist.sys.locale. (Narayan Kamath) 2015-01-15
|/ /  
* |   f19176f  Merge "Add + code handling logic for SMS Global Roaming" (Robert Greenwalt) 2015-01-21
|\ \  

You can create aliases for these by adding a section like this to your "$HOME/.gitconfig"

[alias]
  lg = log --graph --date=short --pretty=format:'%C(auto)%h %d %s (%Cgreen%an%Creset) %Cblue%ad%Creset'
  lga = log --graph --date=short --pretty=format:'%C(auto)%h %d %s (%Cgreen%an%Creset) %Cblue%ad%Creset' --all

Then you can run git lg, git lg --all or git lga

Subscribe to All Posts - Wesley Tanaka