Git Tips A better git log

Our tips for your git log

Adept at the Git command line, I use very often git log to know where I am, what has been done lately or check that certain orders went well as expected. However, the default display is a bit heavy for my taste… Lots of space per commit.

To make this all more concise/practical, one can add a "format" part to the git configuration file .gitcongig, at the root of the personal folder. It contains all the global configurations made by the user, and a quick copy / paste allows you to find your favorite configuration on any machine (and OS for that matter!). This file also has the advantage of being readable and directly modifiable if necessary (change name and email for example).

My "Peaks version" looks like this:

[User]
  email = jchevalier@mitrul.com
  name = Jules Chevalier
[core]
  editor = nano
[merge]
  tool = meld
[mergetool]
  keepBackup=false
[format]
  pretty = format:%C(reverse yellow)%h%C(auto) %C(ul normal)%s%C(auto) %d%n%C(reset)%aN <%aE> %C(cyan) %ad %C(green)(%ar)%n    
[log]
  date=local

As for the format of the logs, it allows you to define how the commits will be displayed with the command git log. Thanks to this, we can gain in readability and keep only the information that we find relevant. To sum up, the %C() allow you to change the color and display style, the others %x are the info to display (%h is the commit number, %s the commit message, etc). To customize this display to your liking, everything is detailed here.

It's obviously a story of personal taste, but I find myself there much more easily, and the compact side allows me to see further in the history.

Marine

Check all
Career area
Subscribe to the newsletter :
These articles may interest you