'vscode - how to get file search (not content) to include (git-) ignored files

Although this is not a direct dev question, but it does relate to a dev tool, which is very related to my development work:

When I search for a file in VSCode (CTRL+P), I see that it doesn't include files and folders that are a part of the .gitignore file.

I can very well see the logic in that, and that's fine, but how can I disable this (default?) behavior? Meaning, I do want this search to include ALL files in the project, regardless to the .gitignore file (or any other ignore file, for that matter).



Solution 1:[1]

Open visual studio code settings (cmd+ , on Mac or Ctrl+,), search for the setting:

Search: Use Ignore Files

and untick the checkbox

enter image description here

Solution 2:[2]

As the screenshot in this answer shows, vscode uses rules in both .gitignore and .ignore. Since Git only recognizes .gitignore, we can negate some rules in .ignore to bring them back in the vscode search result.

A demo:

.gitignore

.env.local

.ignore

!.env.local

This trick also works for tools like rg and fd.

Solution 3:[3]

Don't know if this was still useful but one way I found out is. There was a search.exclude setting in the config option

Nornally we would use it to exclude pattern by set it to true. However, we could force the inclusion of excluded pattern by setting the rule as false

{
    "files.exclude": {
        "**/*.asset":true,
        "**/*.mat":true,
        "**/*.meta":true,
        "**/*.prefab":true,
        "**/*.unity":true,
    },
    "search.exclude": {
        "**/*.asset":false,
        "**/*.mat":false,
        "**/*.meta":false,
        "**/*.prefab":false,
        "**/*.unity":false,
    }
}

This is my setting for unity project and this was made all the meta files that was ignored missing from explorer. But I still be able to searching its content

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gbalduzzi
Solution 2 Ian Yang
Solution 3 Thaina Yu