Collin Anderson
Collin Anderson

Reputation: 15424

Search full git commit message body

git log --grep=searchstring appears to only search the first line of every commit message. How do I search the entire commit message?

Upvotes: 1

Views: 369

Answers (1)

larsks
larsks

Reputation: 311258

What version of git are you using? With version 1.7.7.6, the --grep option appears to search through the entire content of commit messages. Take for example this log:

$ git log
commit 7d3f6ed90467f40de32ea4e59f8fa4172735d577
Author: Lars Kellogg-Stedman <[email protected]>
Date:   Wed May 9 14:10:12 2012 -0400

    i added a file

    this is the second line.

commit 3aaf84486d0f1eb41fb5406254f795a581ef0ce2
Author: Lars Kellogg-Stedman <[email protected]>
Date:   Wed May 9 14:10:01 2012 -0400

    i made a change

commit eb6cd7773ff68808a9eda2e7edb8fbffcc1f6759
Author: Lars Kellogg-Stedman <[email protected]>
Date:   Wed May 9 14:09:45 2012 -0400

    this is the first line

    this is the second line

If I grep for the word second, I get:

$ git log --grep=second
commit 7d3f6ed90467f40de32ea4e59f8fa4172735d577
Author: Lars Kellogg-Stedman <[email protected]>
Date:   Wed May 9 14:10:12 2012 -0400

    i added a file

    this is the second line.

commit eb6cd7773ff68808a9eda2e7edb8fbffcc1f6759
Author: Lars Kellogg-Stedman <[email protected]>
Date:   Wed May 9 14:09:45 2012 -0400

    this is the first line

    this is the second line

This is clearly matching something other than the first line.

Upvotes: 1

Related Questions