Create a good looking git commit tree in terminal

Git log is a powerful command, but the output can be very boring and linear. What if you could make it look like this:

* 29d5e16 (feature_x) Added file x.
| * 593f99e (HEAD -> bugFix, origin/bugFix) Added YAY to file.
| * 246efc2 Added a file.
|/  
* e81be5c (origin/master, master) Initial commit

This is basically git log with some bells and whistles added. I have created an alias called lol for this. You can call it what you want. Here is how you add it to your global git config:

$ git config --global alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit --all"

Now you can use it:

$ git lol
* 29d5e16 (feature_x) Added file x.
| * 593f99e (HEAD -> bugFix, origin/bugFix) Added YAY to file.
| * 246efc2 Added a file.
|/  
* e81be5c (origin/master, master) Initial commit

Here is a breakdown of all the flags used:

  • --graph creates a the graphical representation of the commit history tree.

  • --decorate the default behaviour is set to short which prints just the name of the branch or tag instead of full ref name

  • --pretty=oneline prints out the commit log content in the form

  • --abrev-commit shortens the 40-byte hexadecimal commit object number.

  • --all shows all the local branches

Subscribe via RSS