Git:一次搜索以任何方式引用特定文件的所有提交?

问题描述 投票:0回答:1

是否可以使用OR语义同时运行这3个动作,并使用标准寻呼机(less来浏览输出内容?

  1. [git log '**/foo.c'(寻找在仓库中某处更新foo.c的提交)]
  2. git log -G foo.c(查找其差异包含字符串foo.c的提交)
  3. git log --grep foo.c(查找其注释中提到字符串foo.c的提交)

https://git-scm.com/docs/git-log

谢谢!

git git-log
1个回答
0
投票

    一个bash会话:
  • git log '**/foo.c'; git log -G foo.c; git log --grep foo.c
一个CMD Windows会话
  • git log "**/foo.c"&& git log -G foo.c&& git log --grep foo.c
  • 如果使用“或”的语义,您只需要查看一次提交,建议您将--oneline添加到日志中,并将结果重定向到文件中。然后,您可以sort|uniq该文件,以<< [one次获得常见提交。

    (git log '**/foo.c'; git log -G foo.c; git log --grep foo.c)>/tmp/f; cat /tmp/f|sort|uniq
    
    © www.soinside.com 2019 - 2024. All rights reserved.