理解带有子目录的 gitignore
understanding gitignore with subdirs
如果我有以下目录布局:
/
- a
- b
- c.txt
及以下.gitignore
b/
它将匹配(即忽略)文件,但如果 .gitignore
是
b/*
不会吧?
这是正确的。路径末尾的目录分隔符不会使其锚定到特定位置,但开头或中间的目录分隔符将使其锚定到 .gitignore
文件所在的目录位于。
来自gitignore(5)
:
If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level.
如果我有以下目录布局:
/
- a
- b
- c.txt
及以下.gitignore
b/
它将匹配(即忽略)文件,但如果 .gitignore
是
b/*
不会吧?
这是正确的。路径末尾的目录分隔符不会使其锚定到特定位置,但开头或中间的目录分隔符将使其锚定到 .gitignore
文件所在的目录位于。
来自gitignore(5)
:
If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level.