简体   繁体   English

如何防止 VSCode 在启动时打开所有 git 存储库?

[英]How to prevent VSCode from opening all git repositories at startup?

Some of the folders in my VSCode workspace contain a large number of git repositories.我的 VSCode 工作区中的某些文件夹包含大量 git 存储库。 Whenever I open VSCode, it spends a lot of time opening all these repositories.每当我打开 VSCode 时,它都会花费大量时间来打开所有这些存储库。 Usually I only need one or two of these repositories.通常我只需要这些存储库中的一两个。 I can close the unneeded repositories, but it takes a lot of time to open and then close them.我可以关闭不需要的存储库,但是打开然后关闭它们会花费很多时间。 Can I change the default behavior, such that no git repository is opened at startup?我可以更改默认行为,以便在启动时不打开 git 存储库吗?

I found a good answer here that discusses these entries for settings.json我在这里找到了一个很好的答案,讨论了设置的这些条目。json

"git.autoRepositoryDetection": false or git.autoRepositoryDetection": "openEditors" "git.autoRepositoryDetection": falsegit.autoRepositoryDetection": "openEditors"

And after trying that out, I realized in my case I had a repo with submodules, so VSCode was following the information in the git repo.在尝试之后,我意识到在我的案例中我有一个带有子模块的回购协议,所以 VSCode 遵循 git 回购协议中的信息。 If someone tries the above setting with no luck, in your project root run如果有人尝试上述设置但没有成功,请在您的项目根目录中运行

git submodule status

if you get back a list, you can tell VSCode to not open those with如果你得到一个列表,你可以告诉 VSCode 不要打开那些

"git.detectSubmodules": false,

For completeness: Presumably you only want the behavior in a specific workspace.为了完整起见:大概您只想要特定工作区中的行为。 To change workspace settings use command要更改工作区设置,请使用命令

Preferences: Open Workspace Settings (JSON)

as described here如此所述

Setting "git.ignoredRepositories": ["<repo_name>"] in the workspace settings JSON seems to help (the change is applied after restarting VSCode)在工作区设置 JSON 中设置"git.ignoredRepositories": ["<repo_name>"]似乎有帮助(重新启动 VSCode 后应用更改)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM