.vscode文件夹是否要提交给源代码控制?

在新项目中,除了设置之外,文件夹为空。json文件。这个文件夹里会有什么东西?它是特定于机器的,特定于开发人员的,比如。vs文件夹,因此不能提交?或者所有开发人员都应该共享这个文件夹,从而提交它?

.vscode/settings文件顶部的注释。json:

// Place your settings in this file to overwrite default and user settings.
{
}

这似乎意味着文件夹应该包含特定于项目的设置,因此应该包含在源代码中。此外,UserVoice上的这篇文章似乎暗示了一些类型会在那里,也建议它应该被提交。


当前回答

答案是“否”,因为.vscode文件夹是这个编辑器的,你不应该把这些个人设置推送到repo,以免让其他人感到困惑,所以你可以把它添加到项目的.gitignore文件中来忽略这些更改

其他回答

答案是“否”,因为.vscode文件夹是这个编辑器的,你不应该把这些个人设置推送到repo,以免让其他人感到困惑,所以你可以把它添加到项目的.gitignore文件中来忽略这些更改

never commit .vscode/settings.json - with the weird exception of search.exclude . If you really need to, be very careful of putting only settings particular of your project that you want to enforce to other developers. for validation, formatting, compilation use other files like package.json, .eslint, tsconfig.json, etc The only .vscode that makes sense to include are complex launch configs for debugging. Be careful, there could be a third party extension in your system that could put private information there !

What you can't do is copy & paste the whole settings.json contents file to .vscode/settings.json. I'm seeing some people doing this and committing the file is an atrocity. In that case you will not only break others workspace but worst, you will be enforcing settings to users that you shouldn't like aesthetics, UI, experience. You probably will break their environments because some are very system dependent. Imagine I have vision problems so my editor.* user settings are personalize and when I open your project the visuals change. Imagine I have vision problems s I need to personalize user editor.* settings to be able to work. I would be angry.

如果你是认真的,不要提交.vscode/settings.json。一般来说,对特定项目有用的设置,如验证、编译,是有意义的,但通常你可以使用特定的工具配置文件,如.eslint、tsconfig。Json,。gitignore, package。Json。等。我猜vscode作者只是添加了简化新人体验的文件,但如果你想认真的不要!

唯一的例外,在非常特殊的情况下可能是search.exclude

好吧,这可能看起来很晚了,但如果你发现忽略.vscode/而不包括任何子文件很难,你可以忽略目录:

.vscode/

然后手动跟踪你想要的文件:

git add -f .vscode/launch.json

f在文件被忽略的情况下也会添加文件。一旦Git看到.vscode/launch的变化。Json,你会被提示像提交其他文件一样提交它们。

这实际上为我工作,因为我遇到了同样的问题,试图忽略.vscode/路径,不包括子文件settings.json

为什么不关注实践,而不是这里的争论呢?

到目前为止,我发现保存.vscode的最大项目之一是Mozilla Firefox。 Firefox团队似乎分享了他们的共同任务和推荐的扩展。

所以我想保留.vscode并不是一个坏主意,只要你知道你在做什么。

当我看到其他分享.vscode的大项目时,我会更新这篇文章。

一个简单的方法来保持你的设置而不提交到你的项目git存储库是创建一个工作区,并添加文件夹。

当您创建一个工作空间时,您需要保存一个文件代码-工作空间。这个文件包含自定义设置,只需将这个文件从git存储库中保存出来,就可以将.vscode添加到.gitignore文件中。