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

Include or exclude files and directories with shell-style globs.

Search only JavaScript files

Restrict matches to paths matching a glob.

bashANYripgrepglobinclude
bash
rg --glob '*.js' 'fetch\(' .
Notes

Use glob filters when file types alone are too broad or when you want path-specific targeting.

Exclude generated files

Skip minified files during search.

bashANYripgrepglobexclude
bash
rg --glob '!*.min.js' 'sourceMappingURL' web/
Notes

Excluding generated assets reduces noise and speeds up scans.

Exclude build directories

Ignore an entire directory subtree.

bashANYripgrepglobdirectory
bash
rg --glob '!dist/**' 'TODO' .
Notes

This is helpful in monorepos that contain both source and build outputs.

Combine several globs

Layer multiple includes and excludes in one command.

bashANYripgrepglobmultiple
bash
rg --glob '*.ts' --glob '!*.d.ts' 'RequestInit' src/
Notes

Multiple globs give precise control without editing ignore files.

Explain ignore and glob decisions

Inspect why paths are included or excluded.

bashANYripgrepdebugglob
bash
rg --debug --glob '!vendor/**' 'openssl' .
Notes

`--debug` is the fastest way to understand why an expected file did not appear.

Type filters

Use built-in or custom file type definitions to search the right files quickly.

Search only Rust files

Use a built-in type definition.

bashANYripgreptyperust
bash
rg -t rust 'Result<' .
Notes

Type filters are easier to read and reuse than complex globs.

Exclude one file type

Search everything except Markdown.

bashANYripgreptypeexclude
bash
rg -T md 'TODO' .
Notes

This is useful when docs generate too much noise during code-focused searches.

Define a custom file type on the command line

Create a reusable ad hoc type mapping.

bashANYripgreptype-addcustom
bash
rg --type-add 'proto:*.{proto,protodevel}' -t proto 'service ' .
Notes

Custom types are ideal for proprietary extensions or mixed conventions.

Inspect all known types

View the file globs behind built-in types.

bashANYripgreptype-list
bash
rg --type-list
Notes

This is useful before deciding whether to use `-t`, `--glob`, or a custom type.

Hidden files and ignore rules

Decide when ripgrep should respect or bypass hidden files and ignore files.

Include hidden files

Search dotfiles and hidden directories too.

bashANYripgrephidden
bash
rg --hidden 'export PATH' ~
Notes

By default, hidden files are skipped to reduce surprise and noise.

Ignore .gitignore and other ignore files

Search everything except hidden/binary defaults.

bashANYripgrepno-ignore
bash
rg --no-ignore 'secret_key' .
Notes

This is useful when investigating generated files or vendored code that ignore rules normally hide.

Disable all automatic filtering

Search hidden, binary, and ignored files.

bashANYripgrepuuueverything
bash
rg -uuu 'TODO' .
Notes

`-uuu` is the blunt-force mode for exhaustive audits.

Use an extra ignore file

Apply additional ignore patterns from a custom file.

bashANYripgrepignore-file
bash
rg --ignore-file .rgignore-local 'password' .
Notes

Great for personal workspace exclusions that you do not want to commit.

Recommended next

No recommendations yet.