#3514·ripgrep

[ignore] "whitelisted"/negated patterns in ignore files are included even if they are otherwise hidden

Author: tmccombsCreated Aug 16, 2026Updated Sep 6, 2026

Please tick this box to confirm you have reviewed the above.

  • I have a different issue.

What version of ripgrep are you using?

ripgrep 15.2.0

features:+pcre2 simd(compile):+SSE2,-SSSE3,-AVX2 simd(runtime):+SSE2,+SSSE3,+AVX2

PCRE2 10.45 is available (JIT is available)

How did you install ripgrep?

pacman (archlinux)

What operating system are you using ripgrep on?

archlinux

Describe your bug.

If .gitignore (or .ignore, etc.) include a negated pattern (starting with "!"), then files that match that are included in the list of files searched/returned even if they would otherwise be excluded because they are hidden.

The man page does include the following for --hidden:

Note that if a hidden file or a directory is whitelisted in an ignore file, then it will be searched even if this flag isn't provided.

However, I think that this behavior is unexpected, as the usual purpose of negating a pattern in .gitignore is to ensure that a file that otherwise would not be tracked in git (because it matches another, more general, pattern) is still tracked, which isn't necessarily an indication that it should be included in the set of files searched by rg (or fd, etc) despite being hidden.

I understand the motivation for this, that such files are probably tracked in git, and are probably important, for some definition of important. However, it seems inconsistent that a hidden file that matches a negated ignore line, because it would otherwise be ignored by a glob ignore rule should be included, but another hidden file that is checked in to git isn't. And also that --no-hidden ignores hidden files, except for sometimes. From a usability standpoint, it seems like it would be better to have an option to include all git-tracked files (including hidden ones) than this "whitelist" functionality.

See also https://github.com/sharkdp/fd/issues/1266.

It's kind of possible to work around this by using -g '!.*' (or -E '.*' in fd) but that's awkward, non-obvious, and doesn't work for windows hidden files.

Even if the default behavior doesn't change, could there be an option in the ignore crate and maybe rg command line to "always ignore hidden files, even if they are 'whitelisted'"?

What are the steps to reproduce the behavior?

$ ls -a
.  ..  .a.b  a.b  .git  .gitignore
$ cat .gitignore
!.gitignore
*.b
!.a.b
$ rg --files
.gitignore
.a.b
$ rg --no-hidden --files
.gitignore
.a.b

What is the actual behavior?

$ rg --files
.gitignore
.a.b

What is the expected behavior?

With the example, directory above, there should be no output.

More generally, hidden files should not be output unless --hidden is used.