directory containing its own name in its `.gitignore` makes searches come up empty

Author: DanilaFeCreated May 5, 2026Updated May 5, 2026

In brief,

$ echo 'lol' > mydir/test.txt
$ echo 'mydir' > mydir/.gitignore
$ ag 'l' mydir
$ ag 'l' mydir/test.txt
1:lol
$ git status mydir
On branch X
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        mydir/

Basically, a directory contains its own name in its .gitignore. This should mean it ignores mydir/mydir. However, instead, the directory itself gets ignored, and searches on it fail.

Source: ggreer/the_silver_searcher