A git alias for a more compact log

I love git. I love using the command line for git. I love the fact that the git bash window lets me run unix-style commands under windows, and I love the sense of clarity and control it gives me.

I also love the way I can set up aliases using a plethora of options for many of git’s commands. Take git log for instance; I find myself checking the logs for a repo quite often, but I’ve seldom had any use for most of the stuff that command prints out, so instead I’ve typically been using something like:

git log --oneline -5.

Today however, I added the following alias in my .gitconfig file:

[alias]
lg = log --format=\"%h:%<|(30) %an: %s\" -6

From now on, git lg will show something like the following, and only for the previous 6 commits:

ad082da: Author Name       : Added some code...
d5b9040: Author Name       : Debugged the bugs in the code
a412d77: Someone Else      : Added bugs.
ab8b15a: John Coder        : Implemented specified functionality.
54ad5d7: Per               : Did me some programming!
61b8c88: Montgomery Clift  : Adding more stuff

Now, I have a more compact log, with only the last few commits, and only the info I tend to be really interested in.

Did I mention that I really like git?

Engage and contribute for the common benefit of mankind!

This site uses Akismet to reduce spam. Learn how your comment data is processed.