Visual Studio 代码 - 基于 .gitignore 的自动排除

Visual Studio Code - Automatic exclude based on .gitignore

我希望 VSCode 根据我的 .gitignore 配置自动排除 files/folders。

对于资源管理器排除,我找到了一个扩展(explorer-excluded-files,它管理 files.exclude 设置),但对于快速打开文件(cmd + p),我没有找到任何东西。

我想我可以尝试调整其他 *.exclude 设置,但我想知道为什么没有一种全局方法可以在所有相关位置排除 .gitignore 条目?否则我必须在每次 .gitignore 更改时手动同步设置。

关于资源管理器,除了您已经找到的现有插件外,还有一个请求正在进行中:Microsoft/vscode issue 38878

但是关于快速打开,issue 41495包括评论:

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.

那么您是否正在使用(当前的 2018 版 VSCode)设置 search.useIgnoreFiles


四年后(VSCode 1.68,2022 年 5 月),此问题已通过 PR 149967 和新设置 explorer.excludeGitIgnore

修复

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

PR 150848 提及:

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