Skip to main content

Gitignore Awareness

Like rg, ag reads ignore files before traversing directories, skipping excluded paths entirely.

Files ag Respects (in priority order)

FileScope
.agignoreag-specific, highest priority
.ignoreShared ignore rules
.gitignoreGit exclusions
.hgignoreMercurial exclusions

What Gets Skipped Automatically

In a typical Node.js project, ag "axios" skips:

  • node_modules/ (listed in .gitignore)
  • dist/, build/, .cache/
  • .git/ (hidden directory)
  • Any binary files (auto-detected)

This makes ag "axios" return only your source code results in milliseconds.

Verifying What Gets Searched

# List all files ag would search (without actually searching)
ag -l ""

# With debugging — shows why files are skipped
ag --debug "pattern" 2>&1 | grep -i "skip\|ignor" | head -20

Overriding Ignore Rules

# Don't respect .gitignore
ag --skip-vcs-ignores "pattern"

# Search hidden dotfiles too
ag --hidden "pattern"

# Search EVERYTHING (like find)
ag -u "pattern" # or --unrestricted

# Search everything twice (completely unrestricted)
ag -uu "pattern"

The -u / --unrestricted ladder:

FlagEffect
(default)Respects all ignore files, skips hidden
-uIgnores .gitignore etc., still skips hidden
-uuIgnores all ignore files AND searches hidden files