Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code - Automatic exclude based on .gitignore

I'd like VSCode to automatically exclude files/folders based on my .gitignore configuration.

For the explorer exclusion I've found an extension (explorer-excluded-files which manages the files.exclude setting), but for the quick open file (cmd + p) I didn't find anything.

I guess I can try and tweak other *.exclude settings but I wonder why isn't there a global method to exclude .gitignore entries in all relevant places? Otherwise I have to manually sync the settings every time .gitignore changes.

like image 700
krulik Avatar asked Nov 06 '16 18:11

krulik


People also ask

How do I create a .gitignore file in VsCode?

Press CTRL + Shift + P ( CMD + Shift + P on macOS) to open the command palette. Type in Add gitignore in the command palette. You'll be presented with a language to generate the gitignore file for. And there you go!

How do I ignore a .cache file in git?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a .gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

How do I get rid of ignored in Visual Studio?

To remove a file from an Ignore List in Solution Explorer, context-click the file and select Manage Files > Remove from Ignore List.


1 Answers

Regarding the explorer, in addition of the existing plugin you have found, there is a request in progress: Microsoft/vscode issue 38878

But regarding Quick Open, issue 41495 includes the comment:

Are those files covered by a gitignore pattern?
It now skips gitignored files by default.
You can disable this with "search.useIgnoreFiles": false if you prefer.

So are you using (with a current 2018 version of VSCode) the setting search.useIgnoreFiles?


Four years later (VSCode 1.68, May 2022), this issue is fixed with PR 149967 and the new setting explorer.excludeGitIgnore

Controls whether entries in .gitignore should be parsed and excluded from the explorer.
Similar to files.exclude.

PR 150848 mentions:

Since this setting only applies to the explorer it is being renamed from files.excludeGitIgnore to explorer.excludeGitIgnore.

like image 78
VonC Avatar answered Sep 22 '22 12:09

VonC