Today I'll share with you a nice 1-line git config that will enhance a lot your git logs.
But let's start from the problem first. When you hit
git log you usually get this output:
There's nothing wrong with it, but it's very verbose, and for the 21 lines of VS code terminal, you only get info on two commits, not much.
Here's the trick.
Open the file
~/.gitconfig and add this line at the end:
# ...other content...
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --branches
Tabs are meaningful here.
Now we have succesfully created a new git alias. To use it, we can simply call
git lg (note the missing
o) and here's what the output looks like:
Here's what you get:
- much more commits in the same space as before
- information is condensed, but all the meaningful info are present
- You can clearly see branches, merges, and remotes
Now, this post would not exist without the excellent git course I followed on egghead. Highly recommended if you, like me, had already met git but wanted to know some more advanced features. (Note: i'm not affiliated. To be precise: I am a subscriber! Yes, i do pay for the content.)