~2 min read
A beautiful way to display your (git) history
Today we're going to talk about git log!
If you're only interested in the command, you can scroll a bit ;)
A short introduction
I know that there is a lot of tools to display your git index (blade, kraken... check the list here). Believe me or not, I never used one.
Well... to be honest, this is a lie :p. Actually, I tried 2 or 3 of those but they never satisfied me as much as the terminal.
You're probably gonna say that working only with the term is fucking hard - if not impossible, and UI softwares were made exactly to simplify your life, but I'm gonna disagree - just by checking how I use vim as an IDE you should have an idea of my way to do things ahah.
Of course, this is not always true - generalisation is a bad thing to do! But we're gonna say that it is, for the sake of this topic!
Later, I'll make another post about the "why you should always learn to do things through your terminal" ~ kind of a rule that I like ~ but not for now.
Getting right back to the subject!
The command git log will show you the history of the current branch you're working on. That is, "when who (did) what" - kinda our own 3w ;)
With 4 to 6 additional options, we're going to change this unsightly printing to an awesome one.
Here is the command:git log --all --decorate --graph --oneline [--color] [--simplify-by-decoration]
And now comes some explanations about the options:
- all -> printing all branches, commits etc. Basically asking for "full git history" instead of "just the current branch"
- decorate -> showing useful informations like the
HEAD, tags etc - graph -> rendering the result as a beautiful graph
- oneline -> making the overall history easier to display because shorter (a commit will literally be rendered in "one line")
- color -> 99% of the time your term/conf will have color enabled by default... 1% of the time you'll need this option ;)
- simplify-by-decoration -> only useful if your history is all messed up and you need a global view of the working tree
You can play with it, adding or removing some options to see the differences.
In short
I STRONGLY recommand you to learn it (and not making an alias or cheating in any way) - though learning to read the graph may take some time.
It will definitely be worth it. I've made a dedicated post to explain "how to learn it", the good way.