git log is so 2005

February 23, 2014

Whether you love terminal customization or feel more Rand Paul with your ‘.bash_profile’, this tip will change your life. This is one of the first commands I run on a new machine, and it has been an invaluable visualization tool for as long as I can remember. 

git config --global alias.lg "log --color --graph --abbrev-commit
           --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset'"

― via Filipe Kiss

This command creates a new ‘git lg’ alias to use instead of the default ‘git log’. What does running git lg do exactly? It turns this mess:

git log example

into this:

git lg example

Beautiful, isn’t it? You get more information above the fold by removing noise. And as an added bonus, you can see your branches ebb and flow across your repository. This can be super helpful for navigation and rebasing, and invaluable within merge-based workflows like GitHub’s.