简体   繁体   English

使用grep搜索所有git commit,然后格式化结果

[英]Search through all git commits with a grep and then format the results

How do I search through all git commits with a grep and then format the results with just the commit hash and the commit notes. 如何使用grep搜索所有git提交,然后仅使用提交哈希和提交注释来格式化结果。

I have tried something like this. 我已经尝试过这样的事情。

git log --pretty=format:%H %N --grep=mysearchtext

Not sure if I am missing some command pipes somewhere. 不知道我是否在某处缺少一些命令管道。

Assuming you're talking about the commit message and not the notes , you don't want to use %N . 假设您在谈论的是提交消息而不是注释 ,那么您不想使用%N Perhaps %s would be better, or %s %b . 也许%s会更好,或者%s %b会更好。 That's up to you. 随你(由你决定。 Also, make sure you single or double quote the --pretty flag so it's not split into two arguments 另外,请确保将--pretty标志用单引号或双引号--pretty起来,以免被拆分成两个参数

git log "--pretty=format:%H %s" --grep=mysearchtext

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM