如何强制ag在node_modules中查找匹配项?

15

我正在使用 ag 搜索 git 存储库。它在我的 node_modules 子目录下找不到匹配项。为什么?如何控制这种行为?

1个回答

18

原来ag默认会尊重.gitignore文件里的内容。所以如果node_modules在.gitignore里面,ag就不会搜索它。这是很明智的行为,但如果你没有预料到这一点,就很难调试。希望这篇文章能够帮助你。

man ag的结尾有一个很好的总结:

IGNORING FILES

   By default, ag will ignore files whose names match patterns in  .gitig-
   nore,  .hgignore,  or  .agignore.  These  files  can be anywhere in the
   directories being searched.  Ag  also  ignores  files  matched  by  the
   svn:ignore property if svn --version is 1.6 or older. Finally, ag looks
   in $HOME/.agignore for ignore patterns. Binary  files  are  ignored  by
   default as well.

   If  you want to ignore .gitignore, .hgignore, and svn:ignore, but still
   take .agignore into account, use -U.

   Use the -t option to search all text files; -a to search all files; and
   -u to search all, including hidden files.

根据我的需求,ag -t 看起来能够很好地工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接