git grep
看起来比常规的 GNU grep
有更简单的规则,这将允许您搜索制表符并使用反斜杠转义特殊字符。我正在尝试查找字符串->upload
的出现次数,但似乎没有任何一种转义方式奏效。如何运行
git grep "->upload"
?$ git grep ->upload
No output; return 0
$ git grep "->upload"
error: unknown switch `>'
git grep "\-\>upload"
No output; return error
$ git grep '->upload'
error: unknown switch `>'
>
无关)。尝试使用git grep -upload
命令,你会看到一个非常相似的问题。 - Charles Duffygit grep '-upload'
,不要加上>
符号 -- 你仍然会收到“未知开关”的错误消息,只是另一个字符成为了最初失败的点。>
符号仅包含在消息中,因为它是在前导-
之后第一个不被识别为有效选项的字符。 - Charles Duffygit grep "->upload"
和git grep '->upload'
是完全相同的(同样适用于git grep -\>upload
),以至于git
无法区分它被称为其中哪一个;在这些情况下,传递给git的main()
函数的C字符串列表完全相同。 - Charles Duffy