git lg
git log
I use git log
regularly to view the past commits. We all know how useful the git log
command is. But it's ugly;
commit cd85270b35d625ddebd74c44782b39a5b8286587
Author: Ian Greulich <----@--------.com>
Date: Thu Sep 26 16:47:16 2013 -0400
WR-184085: new image f/medical plan cart
commit 296ec25ecfe26ef6a0f89f28b9390607dd4dd689
Author: Ian Greulich <----@--------.com>
Date: Thu Sep 26 16:04:07 2013 -0400
WR-184085: fixes from QA
commit cd6a0e61b55e564c2af880ca616f2b799e7ac40f
Merge: 7de6ced 3c50403
Author: Tony Malatanos <----@--------.com>
Date: Wed Sep 25 17:51:03 2013 -0400
Merge pull request #4 in UXG/goblin from ~IGREULICH/goblin-fork:develop to develop
But there is a lot we can do to make this… more meaningful;
Enter git lg
By aliasing a fancy log
in your ~/.gitconfig
;
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
when you run git lg
, you get a much nicer output;
* cd85270 - (HEAD, origin/feature/legacy, origin/WR-184085_fix, feature/legacy, WR-184085_fix) WR-184085: new image f/medical plan cart (17 hours ago) <Ian Greulich>
* 296ec25 - WR-184085: fixes from QA (18 hours ago) <Ian Greulich>
* cd6a0e6 - Merge pull request #4 in UXG/goblin from ~IGREULICH/goblin-fork:develop to develop (2 days ago) <Tony Malatanos>
|\
| * 3c50403 - WR-184085: tweak edit/remove link positions (2 days ago) <Ian Greulich>
| * c63b408 - WR-184085: fix nth-type-of (2 days ago) <Ian Greulich>
| * 6bfd1bd - WR-184085: tweak style to fix inconsistancies (2 days ago) <Ian Greulich>
| * 4fe8f72 - (origin/WR-184085) WR-184085: finish the style changes, added new images (2 days ago) <Ian Greulich>
| * 0ef58e4 - WR-184085: update plan listing page (4 days ago) <Ian Greulich>
| * e1b8a16 - WR-184085: update progress indicator, some of plan comparison page (4 days ago) <Ian Greulich>
| * 876f2c3 - WR-184085: update hope page center content (4 days ago) <Ian Greulich>
| * 308bf10 - WR-184085: update footer (4 days ago) <Ian Greulich>
| * df71560 - WR-184085: add oswald font, update main header text styles (4 days ago) <Ian Greulich>
| * ea45ca0 - WR-184085: update header nav (7 days ago) <Ian Greulich>
Much nicer, right?
--graph
gives you the graph you see on the left, the * indicates the branch the commit was made to, but --format=<blah>
is where the magic really happens.
--format
Basically --format
lets you manipulate the output of log
into essentially any format you like (See git log --help
for more detail). I have the following;
-
%Cred%h%Creset
prints the abbreviated sha:%h
, in red, then resets the color -
-
prints a dash -
%C(yellow)%d%Creset
prints the ref names:%d
in yellow, then resets the color -
%s
prints the subject, or commit message -
%Cgreen(%cr)
prints the commit date, relative:%cr
in green and parenthesis -
%C(bold blue)<%an>%Creset
prints the authors name:%an
in blue, and brackets, then resets the color
This makes the output from lg
much more useful, and easier to read.
Written by Ian Greulich
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
khasinski
591.1K
dmichaelavila
500.4K
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#