git log --grep=searchstring
似乎只搜索每个提交消息的第一行。如何搜索整个提交消息?
答案 0 :(得分: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
如果我找到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
这显然与第一行不同。