Today I Learned

hashrocket A Hashrocket project

After context in Grep

This is my standard grep through a git log:

$ git log | grep 'Extract oauth'
    Extract oauth response parsing

Cool; I found the commit I wanted. However, there is no context here-- I don't know the SHA, date, or committers.

Enter the -a flag, which stands for 'after context'. This flag will add some context to my results.

$ git log | grep 'Extract oauth' -a5 

commit 8e451afl4f292fb86ebbeca8baf5c9578355d3bf
Author: Liz Lemon and Jack Donaghy <dev+lizlemon+jackdonaghy@hashrocket.com>
Date:   Tue Apr 28 10:48:02 2015 -0500

    Extract oauth response parsing

commit a4d16le46ed4286732019c0024db07c85a179210
Author: Liz Lemon and Jack Donaghy <dev+lizlemon+jackdonaghy@hashrocket.com>
Date:   Tue Apr 28 10:17:54 2015 -0500

Now I can git show or git checkout that SHA, or anything else I need to do.

See More #command-line TILs