使用注释搜索git日志



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

现在有一个很久以前的提交,我记得提交消息的一部分,当我执行git log --stat | grep 'message text'时,日志只显示包含'message text'的提交消息。

但是,我至少需要看到提交id和grep结果。我该如何做到这一点?

试着用这个来获取完整的信息。

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

尝试使用--oneline:

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

否则,通过less管道输出结果,并使用less进行搜索:

git log | less
/message text

使用grep的选项来显示更多的上下文行。选择适当大小的num来查看您的id。

grep -A num -B num

这将查找您的注释。

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

Atlassian Documentation for git log向下滚动到"By Message"查看更多细节。

可以使用两次——author。我需要查找两个开发人员所做的一组签入。这是我最喜欢的大海捞针的方法。——pretty=online做两件事,1)每次提交都在一行上,2)显示完整的提交引用号。只要使用——online就可以得到相同的结果,只是提交引用号被缩写了。

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.

最新更新