A while back, I wrote a post about how to improve the log command in git by adding a customized alias for it. I’ve been fairly happy with that alias, but I kept missing one thing: A date, or some similar indicator of the age of each commit. Today, I finally set aside time to improve it, and here`s the result:
lg = log --format=\"%h: %Cgreen%an %ar %Creset(%ci) %n %s\" -10
I lock my PC every time I leave it (Shortcut: Win + L), and until recently, that would cause my screen to shut off too after only a minute. When it can take upwards of 30 seconds to turn the screen back on, that can get pretty annoying if you’re just gone for that one minute.
You would perhaps think there was a simple setting for adjusting the time it takes before your screen turns off – and there is – but for some reason, it seems to be disabled and hidden in Windows by default. To enable it, you’ll need to make a change to your Windows registry. Once you’ve done that, you can easily adjust the timeout as you like.
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:
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.