是否有多个`.gitignore'皱眉? [英] Are multiple `.gitignore`s frowned on?
问题描述
.gitignore
文件比最简单的文件要简单得多。有没有一个标准的最佳做法,或者在线分析一种方法比另一种更好? 在至少两种情况下,您希望在不同(子)目录中具有多个 .gitignore
文件。 -
不同的目录有不同类型的文件要忽略。例如,项目顶部目录中的
.gitignore
会忽略生成的程序,而Documentation / .gitignore
会忽略生成的文档。 -
忽略给定文件只能在给定的子目录中使用
/ sub / foo
$ b请记住 .gitignore 文件递归地应用于文件所在的(子)目录及其所有子目录,除非模式包含'/'(例如模式
name
适用于给定目录及其所有子目录中名为
name
的任何文件,而/ name
最适用于文件只在给定的目录中有这个名字)。Unless a repo consisted of several independent projects, it seems it would be simplest to just have one
.gitignore
file at the root of the repo than various ones throughout. Is there a standard best practice on this or some analysis online of when one approach is better than the other?解决方案I can think of at least two situations where you would want to have multiple
.gitignore
files in different (sub)directories.Different directories have different types of file to ignore. For example the
.gitignore
in the top directory of your project ignores generated programs, whileDocumentation/.gitignore
ignores generated documentation.Ignore given files only in given (sub)directory (you can use
/sub/foo
in.gitignore
, though).
Please remember that patterns in
.gitignore
file apply recursively to the (sub)directory the file is in and all its subdirectories, unless pattern contains '/' (so e.g. patternname
applies to any file namedname
in given directory and all its subdirectories, while/name
appliest to file with this name only in given directory).这篇关于是否有多个`.gitignore'皱眉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!