Globs, Types, and Ignore Rules

Control what ripgrep searches with globs, type filters, hidden files, and ignore behavior.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Glob filters
Search only JavaScript files
rg --glob '*.js' 'fetch\(' .

# Restrict matches to paths matching a glob.

Exclude generated files
rg --glob '!*.min.js' 'sourceMappingURL' web/

# Skip minified files during search.

Exclude build directories
rg --glob '!dist/**' 'TODO' .

# Ignore an entire directory subtree.

Combine several globs
rg --glob '*.ts' --glob '!*.d.ts' 'RequestInit' src/

# Layer multiple includes and excludes in one command.

Explain ignore and glob decisions
rg --debug --glob '!vendor/**' 'openssl' .

# Inspect why paths are included or excluded.

## Type filters
Search only Rust files
rg -t rust 'Result<' .

# Use a built-in type definition.

Exclude one file type
rg -T md 'TODO' .

# Search everything except Markdown.

Define a custom file type on the command line
rg --type-add 'proto:*.{proto,protodevel}' -t proto 'service ' .

# Create a reusable ad hoc type mapping.

Inspect all known types
rg --type-list

# View the file globs behind built-in types.

## Hidden files and ignore rules
Include hidden files
rg --hidden 'export PATH' ~

# Search dotfiles and hidden directories too.

Ignore .gitignore and other ignore files
rg --no-ignore 'secret_key' .

# Search everything except hidden/binary defaults.

Disable all automatic filtering
rg -uuu 'TODO' .

# Search hidden, binary, and ignored files.

Use an extra ignore file
rg --ignore-file .rgignore-local 'password' .

# Apply additional ignore patterns from a custom file.

Recommended next

No recommendations yet.