在我的存储库中,我有以下目录结构:
/
|-dir1
| |-file1
| |-file2
| |-file3
|-dir2
| |-file4
| |-file5.derp
| |-file6
|-dir3
|-file7
|-file8
我的.gitignore
文件(位于根目录)如下:
dir2/
!dir2/*.derp
但是,git add
从未找到file5.derp
...
我在这里缺少什么?
最佳答案
尝试像这样的 .gitignore:
dir2/*
!dir2/*.derp
每个 gitignore 手册页:http://www.kernel.org/pub/software/scm/git/docs/gitignore.html
If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git).
我怀疑它忽略了该目录中的所有文件,并且没有达到使用 ! 进行检查的程度。
关于Git 忽略陌生事物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14858914/