Advent Day 9: git lol

December 9, 2018

This is day 9 of my Git Tips and Tricks Advent Calendar. If you want to see the whole list of tips as they're published, see the index.

There are two commands I run more than any other: first, git status which lets me know what I've been working on. Second, git log which lets me know what other people have been working on.

git log

But I don't actually use git log. Usually I run git lol. Now, if you've just said to yourself "what's git lol?" and gone and run it, apologies. There's actually no git lol command out of the box. I've made an alias for it. It stands for:

git log --one-line

Which is a handy flag that shows you the commit history, one on each line. It omits the extended commit description and just shows you the commit ID and title:

git log --oneline

(That git lol is sort of fun to type is also nice.)

And actually, I've extended the alias a bit over the years to also add the --graph flag, which will show me the graph on the left, helping me better understand the flow of commits into the project:

git log --oneline --graph

You can enable this by running:

git config --global alias.lol 'log --oneline --graph'

And of course you can add your own flags to customize the history behavior to what you want to see. Do you want to just see only the merge commits, so that you see the pull requests that got merged and not each individual commit inside of them? You can use the --first-parent flag to git log.

Ultimately, though, I'd encourage you to use aliases to make your git commands work best for you in your preferred workflow.