gpt4 book ai didi

gitignore - gitignore 递归行为在哪里指定?

转载 作者:行者123 更新时间:2023-12-04 14:32:09 29 4
gpt4 key购买 nike

引用the online docs :

If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file (relative to the toplevel of the work tree if not from a .gitignore file).



对我来说,这个文档说给定一个模式 'foo',任何名为 'foo' 的文件或目录将仅相对于 .gitignore 文件被忽略。我没有阅读任何解释其递归行为的内容。 Shell glob(来自 what I read 和经验)不是递归的。

现在进一步解释双星号:

A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo"



所以是的,文档中有一个例子解释了 **/foo等于 foo ,但递归行为仍然是隐含的。

最佳答案

像“foo ”这样的规则的递归性质来自于这些规则的获取和应用方式:

Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file.



因此,即使 .gitignore 下有多个子目录,规则“ foo”仍将适用于在所述子文件夹中找到的任何“ foo”文件。

关于gitignore - gitignore 递归行为在哪里指定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31461236/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com