DEV Community

Matt seymour
Matt seymour

Posted on

Making git log prettier

Git without saying is a fantastic tool; but git log by default is a little ugly and actually sometimes can be a little difficult to read branches and merges quickly and accurately.

Here is an example output of basic git log:

git log output basic

Hmm, well we have a list of commits that's useful. But what about when we want to see a log of two branches or where a branch starts and ends. It's a little confusing.

Lets see if we can improve git log by writing a new alias git graph.

git config --global alias.graph "log --pretty --color --decorate --graph"

Command break down:

  • git config - the git config command
  • --global - this is going to be a global config change. You will be able to access this command in all projects.
  • alias.graph - we are going to be adding to the alias section an alias called graph. If you look in ~/.gitconfig later you will see the command.
  • "log --pretty --color --decorate --graph" - the git command we will run when the alias is called.

To run the new alias we now run the command:

git graph

From the screen shot below you now see clearly see the points where merges and branches take place.
Full git graph view

Top comments (3)

Collapse
 
markhu profile image
Mark
Collapse
 
pavelloz profile image
Paweł Kowalski

I recommend tig :) - github.com/jonas/tig

Collapse
 
matt profile image
Matt seymour

It is another option and very good.