git - 当我在子目录中时,如何在整个树中进行 git grep?

标签 git grep

通常当我发出 git grep 时,它只会搜索当前目录及以下目录,例如

$ cat A
1
$ cd d
$ cat B
1
$ git grep 1
B:1
$ cd ..;git grep 1
A:1
B:1

我如何告诉 git grep “搜索整棵树,无论我在当前工作目录中”?

最佳答案

:/魔法路径

git grep pattern -- :/

适用于此命令和其他命令的 Git 1.9.1,如以下位置所述:https://stackoverflow.com/a/31696782/895245

TODO 在 grep 文档后我找不到清晰的文档引用,但发行说明中有时提到了它:

Documentation/RelNotes/1.7.6.txt:39: 是空操作,但是“git add -u :/”会添加更新的内容

关于git - 当我在子目录中时,如何在整个树中进行 git grep?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10868591/

相关文章:

git - Tortoisegit:如何从新的远程分支获取?

mysql - 无法从损坏的 MySQL 转储文件访问表

git - 更改 GIT 端口

带有排除的 Git 稀疏 checkout

regex - 如何优化 grep 正则表达式以匹配 URL

linux - 在 Linux 中 Grep 字符串

regex - bash 正则表达式 : Search for a maximum of 3 consecutive vowels

bash - 如何在bash中更新文件中的多字符分隔字段?

git-p4 提交失败,出现 'Path is not under client' s root 错误

Xcode 机器人 : git submodules not initialized