You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Find in Files "files to include" override .gitignore #26574
feature-requestRequest for new features or functionalitysearchSearch widget and operation issuesupstream-issue-linkedThis is an upstream issue that has been reported upstream
VSCode 1.12: I have a TypeScript project with a src folder and a .gitignore file containing this:
/src/**/*.js
If I search for something, it is OK with 'files to include' is empty:
but it is not OK if I scope the search:
While I'm searching only in some sup-tree of my project, all .gitignore rules should still be taken into account.
Reacted by Anton Fedchenko, Mark Knapp, Ben Shepheard, Aliaksei Kislou, Alex Kessock, Ethan Edwards, Nikhil Verma, Nick Breaton, Alex Rattray (Stripe), Mangala Khalsa and 87 more
Reacted by Leon Heess, VonC, Haoran Ni, Jonas Hammerschmidt, Islam, Jiri Spac, Brian and Faheem Iqbal
It seems like ripgrep will let include globs override entries in the gitignore file. I'm not sure whether that's expected or whether we can change that. But one workaround is to use ./src syntax in 'files to include'.
./src seems to be broken again - regardless of syntax put to files to include .gitignore is no longer respected by ripgrep. I'm pretty sure it worked before, maybe ripgrep API change?
Sorry I see, the workaround I mentioned above will not work anymore. The only suggestion I have right now is to add patterns to search.exclude as well. I'll have to figure out why ripgrep handles gitignore patterns differently.
searching with files to include being empty finds nothing
searching with ./front in files to include finds xxx
As a proposal: maybe vscode should always search from root and filter with files to include afterwards in memory just for UI. More work but it's near instant with ripgrep anyway.
There have been similar comments above, but since we're in an AI world now, I figured I'd help the community with an AI-first solution that solved this for me (even tho it's not 100% robust to changes, it does solve the issue for me, and it can always be re-run again).
Run find . -maxdepth 2 -name ".gitignore" | xargs cat to print out all the gitignores (change maxdepth if needed for your purposes)
Run the following prompt in Claude:
Here are all my gitignores for all shared repos
-----
INSERT ALL GITIGNORES HERE
-----
Here is my VSCode setting
-----
"search.exclude": {
"**/node_modules": true,
INSERT ANY OTHER EXISTING search.exlude VALUES HERE
}
-----
Write a full version of search.exclude that'll exclude the all of the files that should be excluded by those gitignores, collectively. I don't want anything that should be gitignored to come back in VSCode search.
Then replace the INSERT statements with the result of (1) and your own existing VSCode settings.
This gives you a COMPLETE list of things to update the VSCode search.exclude setting with, and for me this fully solves the issue. Could turn this into an automated script with an LLM API call if you really find it getting out of date often. And if it doesn't work perfectly the first time, I'm sure a small tweak to the prompt would get it working reliabily.
Hope it helps.
Reacted by Harri Lehtola
Reacted by Andrew, Mikael Finstad, J. Ryan Stinnett, Leon Heess, Lau Kondrup, Dan Dean, Mikhail Bulash and Faheem Iqbal
So the issue to update ripgrep was closed because apparently a PR was merged to do so. But after cloning the main branch, I can still reproduce this bug. i.e.: for the same search query, i get waaay more results when specifying a subfolder search path, than when I search on the root folder, as the ignored files are not actually ignored when specifying a subpath.
I'm not sure if i'm doing it wrong, i got the wrong branch without the fix, or something, or if the fix doesn't actually work. I'd appreciate if someone could try to reproduce this too, so we can know if it's actually fixed or not.
Edit: but that was merged only 5 days ago, so I expect it will take until the next release for us. It does appear to finally update to ripgrep 15, from the dependencies I just checked through that were just updated.
Keavon Chambers (@Keavon) That's exactly what I just wrote, the PR to update ripgrep was merged, and thus I tried to repro the bug in the main branch, which should have the udpated ripgrep dependency with the upstream fix, and i sadly still manage to reproduce the bug :/
Thus I ask if other people also reproduce the bug on the main branch, or if i did something wrong. I'm not sure what you're trying to say?
I'm finding this annoying too. Is this fundamentally a problem with ripgrep (i.e. it doesn't have an option to have this behaviour) to VSCode (as in ripgrep can achieve this but VSCode just isn't using the option)? Or is it that ripgrep didn't have this option and now does but VSCode isn't using the latest ripgrep version?
Even a simple wildcard like *.scss will make it ignore .gitignore files, even though both options to use .gitignore are enabled in the settings AND in the search panel.
Adding a file inclusion filter can never cause it find more files than without it, since you're telling it to restrict, not broaden, the files to search through.
It reminds me of those oldie-worldie search engines, where adding more search terms caused them to return more results, not fewer 😄
feature-requestRequest for new features or functionalitysearchSearch widget and operation issuesupstream-issue-linkedThis is an upstream issue that has been reported upstream
Activity
roblourens commentedon May 14, 2017
It seems like ripgrep will let include globs override entries in the gitignore file. I'm not sure whether that's expected or whether we can change that. But one workaround is to use
./srcsyntax in 'files to include'.kompot commentedon Feb 28, 2018
./srcseems to be broken again - regardless of syntax put tofiles to include.gitignore is no longer respected by ripgrep. I'm pretty sure it worked before, maybe ripgrep API change?roblourens commentedon Mar 7, 2018
Unfortunately that's because I changed it to not use gitignore files in parent directories which breaks that workaround.
kompot commentedon Feb 19, 2019
This was working OK up to version 1.30.
1.31 broke this.
roblourens commentedon Feb 19, 2019
Can you explain what you mean by "this"? This issue has been open for a long time.
roblourens commentedon Feb 19, 2019
Sorry I see, the workaround I mentioned above will not work anymore. The only suggestion I have right now is to add patterns to
search.excludeas well. I'll have to figure out why ripgrep handles gitignore patterns differently.kompot commentedon Feb 20, 2019
Seems like it's discussed in this ripgrep issue
BurntSushi/ripgrep#829
UPD
and there's even an unmerged PR
BurntSushi/ripgrep#963
roblourens commentedon Feb 20, 2019
I can't tell whether that's the right issue or not. vscode does not invoke rg with a path argument, the
./syntax is converted to glob patterns.kompot commentedon Feb 20, 2019
Right now I observe this bug/feature/behaviour both in vscode and in rg console output.
I have a file at path
front/build/1.html. It contains stringxxx. Directoryfront/buildis gitignored.rg xxxfrom project root finds nothingrg xxx -g "front/**/*"findsxxxsame happens in vscode
searching with
files to includebeing empty finds nothingsearching with
./frontinfiles to includefindsxxxAs a proposal: maybe vscode should always search from root and filter with
files to includeafterwards in memory just for UI. More work but it's near instant with ripgrep anyway.roblourens commentedon Feb 20, 2019
When searching a big repo, there can actually be a large perf gain by using
./vs searching everything.roblourens commentedon Oct 9, 2019
I am pretty sure BurntSushi/ripgrep#829 is the correct upstream issue for this.
20 remaining items
tsheaff commentedon Jun 8, 2025
There have been similar comments above, but since we're in an AI world now, I figured I'd help the community with an AI-first solution that solved this for me (even tho it's not 100% robust to changes, it does solve the issue for me, and it can always be re-run again).
find . -maxdepth 2 -name ".gitignore" | xargs catto print out all the gitignores (change maxdepth if needed for your purposes)Then replace the INSERT statements with the result of (1) and your own existing VSCode settings.
This gives you a COMPLETE list of things to update the VSCode
search.excludesetting with, and for me this fully solves the issue. Could turn this into an automated script with an LLM API call if you really find it getting out of date often. And if it doesn't work perfectly the first time, I'm sure a small tweak to the prompt would get it working reliabily.Hope it helps.
mcandre commentedon Jun 9, 2025
AI is garbage, 100% would not recommend.
Fix VSCode's stock behavior.
simon-id commentedon Aug 20, 2025
I think this has been resolved in unreleased commits in ripgrep: BurntSushi/ripgrep@c2f1653
simon-id commentedon Sep 21, 2025
The fix has now be merged in ripgrep's master and should be released soon. Now I'm trying to convince the vscode team to update it here: #263124
simon-id commentedon Feb 4, 2026
So the issue to update ripgrep was closed because apparently a PR was merged to do so. But after cloning the main branch, I can still reproduce this bug. i.e.: for the same search query, i get waaay more results when specifying a subfolder search path, than when I search on the root folder, as the ignored files are not actually ignored when specifying a subpath.
I'm not sure if i'm doing it wrong, i got the wrong branch without the fix, or something, or if the fix doesn't actually work. I'd appreciate if someone could try to reproduce this too, so we can know if it's actually fixed or not.
Keavon commentedon Feb 4, 2026
Yes, it has never been fixed in VS Code.
Edit: but that was merged only 5 days ago, so I expect it will take until the next release for us. It does appear to finally update to ripgrep 15, from the dependencies I just checked through that were just updated.
simon-id commentedon Feb 4, 2026
Keavon Chambers (@Keavon) That's exactly what I just wrote, the PR to update ripgrep was merged, and thus I tried to repro the bug in the main branch, which should have the udpated ripgrep dependency with the upstream fix, and i sadly still manage to reproduce the bug :/
Thus I ask if other people also reproduce the bug on the main branch, or if i did something wrong. I'm not sure what you're trying to say?
hskrtich commentedon Feb 4, 2026
The ripgrep 15 change has just been included in an insider build of VS Code. So it may be a good idea to test to see if this is still an issue.
webdevelukas commentedon May 21, 2026
This is still an issue in VS Code Version 1.121
simon-id commentedon May 21, 2026
I'm also not seeing an improvement on this issue in recent versions of vscode :/
mcandre commentedon May 22, 2026
Keep the comments rolling in. Microsoft has a nasty habit of arbitrarily closing bug reports over time.
clintonmead commentedon Jun 5, 2026
I'm finding this annoying too. Is this fundamentally a problem with
ripgrep(i.e. it doesn't have an option to have this behaviour) to VSCode (as inripgrepcan achieve this but VSCode just isn't using the option)? Or is it that ripgrep didn't have this option and now does but VSCode isn't using the latestripgrepversion?domenicogemoli-kaiko commentedon Sep 29, 2026
Still an issue
thany commentedon Nov 25, 2026
Even a simple wildcard like
*.scsswill make it ignore.gitignorefiles, even though both options to use.gitignoreare enabled in the settings AND in the search panel.Adding a file inclusion filter can never cause it find more files than without it, since you're telling it to restrict, not broaden, the files to search through.
It reminds me of those oldie-worldie search engines, where adding more search terms caused them to return more results, not fewer 😄