I'm a programmer specialising in performant and scalable systems using PHP and Ruby and cooking


Published:

Improving git log

One of the processes we use here is seperate branches per bug/feature ticket. This keeps changes agnostic and means we can release individual tickets with affecting any others or breaking anyone elses working copy.

git log is a life saver when you need to remind yourself where you got to with your commits, however it's not that handy to see what was merged into the current branch and what was changed in those branches.

So lets make git log more useful; we're going ot use a couple of things here. One being the ability to create aliases to commands in your git config and the other is a collection of options passed to git log. The things we're going to achieve are:

  • Show the commit histroy including commits inside branches
  • Show where branches diverged from the current branch and when they were merged back in
  • Colour code the output for readability
  • Abbreviate the information
  • Finally, make the output pretty!

Simply paste the below line into your global git config (or your local one if you don't have a global one) underneath the "[alias]" section:

lg = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit --"  

Here is my config for reference.