-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Advanced Usage
By default, Ag will read the patterns in .gitignore and .hgignore files in directories it searches. If your source control doesn't care about a file, why should your source-searching program?
- Patterns with Single asterisks
*
must be prefixed with a leading/
. Example:- Bad:
my-folder/*/vendor/*
- Good:
/my-folder/*/vendor/*
- Bad:
- Currently double asterisks
**
patterns in .gitignore and .hgignore are not recognized.- See this issue for details and workaround.
You can also create .ignore
files to ignore things that are in your source repository. .ignore
uses the same patterns as .gitignore
and .hgignore
. Using .ignore
can drastically improve search speeds. A common speedup is to ignore extern. If you want a global .ignore
file, consider adding this alias: alias ag='ag --path-to-ignore ~/.ignore'
to your ~/.bash_profile
(or similar) file.
The .agignore
file was removed in favor of .ignore
as part of the 2.0.0 release.
The -G option lets you specify a regex of file names to search. Any file name not matching this pattern will be ignored. For example, ag -G manager class
will find instances of the string "class" in all files with the string "manager" in their name.