Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
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?
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
.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.
.agignore file was removed in favor of
.ignore as part of the 2.0.0 release.
Ignoring from the command line
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.