使用评论搜索git log

时间:2016-10-05 09:38:47

标签: git terminal git-bash git-log

我使用git log --stat检查我的git日志,它显示了所有提交以及这些提交中更改的文件。

现在有一个很久以前的提交,我记得提交消息的一部分,这样当我git log --stat | grep 'message text'时,日志只显示存在'消息文本'的提交消息。 / p>

但是,我需要至少看到提交ID以及grep结果。我如何实现这一目标?

4 个答案:

答案 0 :(得分:2)

尝试使用--oneline

git log --oneline | grep -F 'message text'

否则,通过less管道您的结果,并使用less:

进行搜索
git log | less
/message text

答案 1 :(得分:1)

尝试使用此功能获取完整信息。

git log --all --grep='Your text here'

使用的Git版本:

git version 2.9.0.windows.1

示例:

$ git log --all --grep='Favourite Module modifie' 

结果:

commit 8226dce6f4f5ffd8143b8aefdee3b9b971040aa0 
Author: Surender Singh <sure**@gmail.com> Date: Thu Aug 25 11:29:32 2016 +0530 
view Favourite Module modified

答案 2 :(得分:0)

使用opts for grep来显示更多上下文行。选择合适的num大小以查看您的ID。

grep -A num -B num

答案 3 :(得分:0)

这将找到您的评论。

git log --grep "search text" --author your_name

Atlassian Documentation for git log向下滚动到“通过消息”以获取更多详细信息。

此外,您可以使用--author两次。我需要寻找由两个开发人员进行的一组签入。这是我在git的干草堆中寻找那根针的最喜欢的方法。 --pretty = online做两件事,1)每次提交都在一行上,2)显示完整的提交参考号。只是使用--oneline可以提供相同的功能,只是缩写了提交引用号。

git log --grep "#Bug" --author jones --author smith --pretty=oneline

\dev8.4> git log --grep "#Bug" --author jones --author smith --pretty=oneline
80334597b56add0ad4a3ddd02e7a6514bf01ad1e #Bug -- Further Mods To Code - CC Save
16cc3b4e949e965de9b72eb4583fa8df659528a0 #Bug -- Use new get charge function to load CC.
b207498261b4622ef88cb696365bf9af2f3fc6e1 #Bug -- Reference now editable after CC scan.
56385b7a77e2ec9af3b827f6a9ba93c22f267e51 #Bug -- Reload Entire Page after CC charge.
19e9cb05dabd8cc7c9a80e64187821d562af043c #Bug -- force Guid after save event.
c363ed97fdc2b56d1fcd84ca48eb300dbb120a3d #Bug -- Guid was getting lost in some cases.