Ripgrep: How to Ignore ".gitignore"

Updated

Learn how to search files listed in .gitignore with ripgrep (rg)

Ripgrep: How to Ignore .gitignore

Before we start, make sure you have ripgrep installed on your computer. On a Mac, you can install it with Homebrew:

brew install ripgrep

By default, ripgrep skips everything in your .gitignore, like node_modules, build folders and log files. To search those files too, open your terminal, go to your project folder and run:

rg -u "pattern"

The -u flag is short for --no-ignore. It still skips hidden files, so an ignored dotfile like .env won't show up yet. To include those as well, add a second u:

rg -uu "pattern"

And to search absolutely everything, binary files included, use -uuu.

If you only want to turn off the Git rules but keep ripgrep's own .ignore and .rgignore files, use --no-ignore-vcs instead.

undefined

If a search suddenly comes back empty, try it again with -u. Nine times out of ten, the file you're looking for is ignored.