Skip to main content

Gitignore Awareness

The single most impactful default in rg is automatic .gitignore respect. This is why rg "TODO" finishes in milliseconds on a project that would take grep -r "TODO" . several seconds.

What Gets Ignored by Default

rg reads and respects these ignore files, from highest to lowest priority:

SourceScope
.rgignore (in any searched dir)Local override, rg-specific
.gitignore (in any searched dir)Standard Git exclusions
.git/info/excludeRepository-level exclusions
~/.config/ripgrep/ignoreGlobal user ignore file
core.excludesFile in ~/.gitconfigGit's global ignore

Practical example: In a typical Node.js project, .gitignore contains node_modules/. When you run rg "axios", ripgrep will not descend into node_modules/ at all — saving potentially millions of file reads.

Creating a .rgignore

.rgignore uses identical syntax to .gitignore, but only rg reads it. Use this when:

  • You want to ignore something for searching but NOT for git
  • You want to override a .gitignore that includes too much
# .rgignore
*.lock
*.snap
coverage/
__pycache__/
*.pyc
dist/

Place .rgignore in your home directory to apply globally to all searches.

Verifying What Gets Searched

Use --debug to see exactly which files rg reads and which it skips:

rg --debug "pattern" 2>&1 | grep -E "ignoring|searching" | head -30

Or use --files to list every file rg would search without actually searching:

# Show all files rg would search
rg --files /var/www/html

# Pipe to wc to count them
rg --files . | wc -l