.gitignore中a /和a / *和a / **的区别? [英] The difference between a/ and a/* and a/** in .gitignore?
问题描述
- a
- b
- b1.txt
- b2.txt
- a1.txt
- a2.txt
- b
- 。 gitignore
首先:如果我想忽略文件夹a, >我想忽略文件夹a中除文件夹b以外的所有内容,唯一的方法是: 我不知道为什么 或者你可以告诉我如何使用 a /
和 a / *
和 a / *第二:
不会被忽略。
a / *
!a / b /
a / **
不能做到这一点?
#这种方式不能除了文件夹b
a / **
!a / b /
a / **
? **
匹配任意数量的目录, *
只有一个。
所以如果你e。 G。忽略 / a / ** / d /
,然后 / a / b / d /
和 / a / b / c / d /
都被忽略。
如果你e。 G。忽略 / a / * / d /
,则 / a / b / d /
c> / a / b / c / d /
如果文件夹被忽略,那么Git甚至不会查看其内容来检查包含。这就是为什么你不能忽略 / a /
然后包含 / a / b /
,因为Git甚至没有看成 / a /
。因此,您必须改用 / a / *
忽略 / a /
中的所有内容,然后包含 / a / b /
忽略 / a /
中的所有内容,除了 / a / b的所有内容/
。
Here is my file folder.
- a
- b
- b1.txt
- b2.txt
- a1.txt
- a2.txt
- b
- .gitignore
Firstly:
I found if I wanna ignore the folder a, a/
and a/*
and a/**
all can complete.
Secondly:
I wanna ignore all the things in folder a except the folder b, the only way to do this is :
a/*
!a/b/
I don't know why a/**
can't do this?
# this way can't except folder b
a/**
!a/b/
Or you can tell me how can I use a/**
?
**
matches any amount of directories, *
only one.
So if you e. g. ignore /a/**/d/
, then /a/b/d/
and /a/b/c/d/
both are ignored.
If you e. g. ignore /a/*/d/
, then /a/b/d/
is ignored while /a/b/c/d/
is not ignored.
If a folder is ignored, then Git does not even look at its contents to check for inclusions. That is why you cannot ignore /a/
and then include /a/b/
, as Git does not even look into /a/
. Because of this you must instead ignore all contents in /a/
with /a/*
and then include /a/b/
to ignore everything in /a/
, except all contents of /a/b/
.
这篇关于.gitignore中a /和a / *和a / **的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!