Git 有可能为标签注册grep吗?

Git 有可能为标签注册grep吗?,git,grep,Git,Grep,指定-p允许GNU grep对选项卡进行grep grep -P '\t' config/file.txt 但是,使用git grep,我无法解决如何grep选项卡: git grep '\t' # Looks for files with the letter "t" instead git grep -P '\t' # Invalid option git grep -E '\t' # Does the same as without the -E 而且在你自己的grep程序中似乎没有替

指定
-p
允许GNU grep对选项卡进行grep

grep -P '\t' config/file.txt
但是,使用
git grep
,我无法解决如何grep选项卡:

git grep '\t' # Looks for files with the letter "t" instead
git grep -P '\t' # Invalid option
git grep -E '\t' # Does the same as without the -E

而且在你自己的
grep
程序中似乎没有替代的选项。我唯一可以选择的方法是:先把全部内容读出来,然后在结果上使用GNU grep?

您可以通过在命令中键入文字选项卡来解决这个问题:

# type it with ^V then tab
git grep '  '

我找不到一个可以工作的标签的regexp符号,但是如果你能传入一个标签,它会很乐意地搜索一个文字标签。在bash中,这将是

git grep $'\t'

在Windows上,以下功能在PowerShell中工作:

git grep "`t"

我想知道
git grep'\\t'
是否有效。对于安全选项卡到空间的大规模转换:这种语法也适用于grep回车:
git grep$'\r'
。如果您需要进行更具体的搜索,例如使用正则表达式匹配行的开头,那么您也可以执行git grep'^'$'\t\t>:D是的。ctrl-v的Bash是什么意思?@three:还不清楚?就像我说的,如果你输入^V然后是tab,你会得到一个文本标签。它逐字(逐字)解释下一次击键,而不是给出特殊的解释。