git忽略特定类型的所有文件,除了特定子文件夹中的文件 [英] git ignore all files of a certain type, except those in a specific subfolder
问题描述
我有这样的目录结构:
现在使用 .gitignore
我想忽略所有 *。 json
文件,除了 spec
中的文件外。我不想在 folder1
和 folder2 $ c中使用
.gitignore
$ c>因为有很多这样的东西,他们会被添加到很多,我确信我会忘记将正确的 .gitignore
文件移到原地。
另外,使用json文件可能会有更多的嵌套目录,并且此规则也需要应用于所有子目录。
那么如何忽略一个类型的所有文件,除了某个子目录? 一个可选的前缀 http://schacon.github.com/git/gitignore.html I have a directory structure like this: Now using a In addition there may be more nested directories with json files, and this rule needs to apply to all subdirectories as well. So how do I ignore all files of a type, except for a certain subdirectory? An optional prefix http://schacon.github.com/git/gitignore.html
这篇关于git忽略特定类型的所有文件,除了特定子文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!!
,它抵消了
模式;
排除的任何匹配文件将重新包含在
中。如果一个否定模式
匹配,这将覆盖较低
优先模式的源。
*。json
!spec / *。json
.gitignore
I want to ignore all *.json
files except for the ones in the spec
. I don't want to use a .gitignore
in folder1
and folder2
because there are a ton of these and they will get added to a lot, and i'm sure I will forget to move the right .gitignore
file in place.
!
which negates the
pattern; any matching file excluded by
a previous pattern will become
included again. If a negated pattern
matches, this will override lower
precedence patterns sources.*.json
!spec/*.json