git .gitignore 中的子文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15057256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Subfolders in .gitignore
提问by syntagma
I have many subfolders in my repo, in which there are few build/
directories I'd like to ignore when committing my code. As I understand it, there are two ways to ignore all of the folders:
我的 repo 中有许多子文件夹,其中build/
在提交代码时我想忽略的目录很少。据我了解,有两种方法可以忽略所有文件夹:
*/build/
(Unix wildcards)build/
(gitway of ignoring files/folders)
*/build/
(Unix 通配符)build/
(git忽略文件/文件夹的方式)
I've found Git ignore sub foldersbut it has two answers and I would like to know what the difference (none?) between the two approaches is. Does the same rule apply to files?
我发现Git ignore sub folders但它有两个答案,我想知道这两种方法之间的区别(没有?)是. 相同的规则是否适用于文件?
回答by Simon
build/
is the right way to do it. It will ignore any files that are inside build
directories no matter how deep are these directories nested in your repo.
build/
是正确的方法。build
无论这些目录嵌套在您的存储库中有多深,它都会忽略目录中的任何文件。
*/build/
means ignore build
directories that are exactly one level deepinside your repo. So for instance files inside build
and foo/bar/build
won't be ignored.
*/build/
意味着忽略在你的 repo深处的build
目录。因此,对于内部实例文件并不会被忽略。build
foo/bar/build
If you need more fine grained control, you can always add specific directories to exclude but also not to exclude using !
as a prefix.
如果您需要更细粒度的控制,您始终可以添加要排除的特定目录,但也可以不使用!
作为前缀来排除。