[英]Gitignore: Ignore all .vscode directories, but include the top-level launch.json
I want to ignore all .vscode
directories that may show up in my repository, except for the top-level one.我想忽略可能出现在我的存储库中的所有.vscode
目录,除了顶级目录。 In that top-level one I want to ignore all files except for the launch.json
.在那个顶级文件中,我想忽略除launch.json
之外的所有文件。
I tried to no extent:我没有尝试过:
**/.vscode/
!/.vscode/
/.vscode/*
!/.vscode/launch.json
**/.vscode/
!/.vscode/
!/.vscode/launch.json
**/.vscode/
!/.vscode/launch.json
**/.vscode/*
!/.vscode/launch.json
**/.vscode/
/.vscode/!launch.json
I'd recommend simply ignoring all of these directories:我建议简单地忽略所有这些目录:
.vscode/
and then manually tracking the file you want :然后 手动跟踪您想要的文件:
git add -f .vscode/launch.json
The -f
adds files even if they're ignored, and once the file is tracked the ignore has no effect on it. -f
会添加文件,即使它们被忽略,一旦文件被跟踪,忽略就不会对其产生影响。 Git will see changes to .vscode/launch.json
and you'll be prompted to commit them just like any other file. Git 将看到对.vscode/launch.json
更改,并且系统会提示您像提交任何其他文件一样提交它们。
I stumbled on this answer and as some sources today claim that its a good idea to commit the launch.json
I wanted to provide the correct answer:我偶然发现了这个答案,正如今天的一些消息来源声称提交launch.json
是个好主意,我想提供正确的答案:
.vscode
!.vscode/launch.json
(You added a slash after !, so the path was considered absolute). (您在 ! 之后添加了一个斜杠,因此该路径被视为绝对路径)。
Simply put these 2 lines in your .gitignore
只需将这两行放在您的.gitignore
.vscode/*
!.vscode/launch.json
First line means, ignore .vscode
folder with all (using *
symbol after /
) of its files.第一行表示,忽略.vscode
文件夹及其所有文件(在/
之后使用*
符号)。 Second line means, exclude (using !
) launch.json
file whereas inside the .vscode
folder第二行表示排除(使用!
) launch.json
文件,而在.vscode
文件夹中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.