1

git log --grep=searchstring似乎只搜索每条提交消息的第一行。如何搜索整个提交消息?

4

1 回答 1

1

你用的是什么版本的git?在版本 1.7.7.6 中,该--grep选项似乎搜索提交消息的全部内容。以这个日志为例:

$ git log
commit 7d3f6ed90467f40de32ea4e59f8fa4172735d577
Author: Lars Kellogg-Stedman <lars@seas.harvard.edu>
Date:   Wed May 9 14:10:12 2012 -0400

    i added a file

    this is the second line.

commit 3aaf84486d0f1eb41fb5406254f795a581ef0ce2
Author: Lars Kellogg-Stedman <lars@seas.harvard.edu>
Date:   Wed May 9 14:10:01 2012 -0400

    i made a change

commit eb6cd7773ff68808a9eda2e7edb8fbffcc1f6759
Author: Lars Kellogg-Stedman <lars@seas.harvard.edu>
Date:   Wed May 9 14:09:45 2012 -0400

    this is the first line

    this is the second line

如果我用 grep 搜索这个词second,我会得到:

$ git log --grep=second
commit 7d3f6ed90467f40de32ea4e59f8fa4172735d577
Author: Lars Kellogg-Stedman <lars@seas.harvard.edu>
Date:   Wed May 9 14:10:12 2012 -0400

    i added a file

    this is the second line.

commit eb6cd7773ff68808a9eda2e7edb8fbffcc1f6759
Author: Lars Kellogg-Stedman <lars@seas.harvard.edu>
Date:   Wed May 9 14:09:45 2012 -0400

    this is the first line

    this is the second line

这显然与第一行以外的内容相匹配。

于 2012-05-09T18:12:07.600 回答