Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Pretty Git Logs

Git

If you want to see a graph of your commit log, then I recommend that you use the following command:

git log \
--abbrev-commit \
--oneline \
--all \
--graph \
--decorate \
--color

Executing it should give you output similar to below:

Now you can see the flow of the changes and easily spot where branches have "died off" etc. The only thing that is annoying is that the line wrapping is ugly with the text breaking the graph, so I recommend you keep your terminal wide. If you know a solution to this then please leave a comment.

Use an Alias

That command can be hard to remember, and long to type, so I recommend adding this line to the end of your .bashrc file

alias gg="git log --oneline --abbrev-commit --all --graph --decorate --color"

Now you only have to type gg to view your logs. Now you're winning.

Last updated: 9th May 2020
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch