Gitignore忽略了我想跟踪的目录

时间:2015-04-11 16:37:34

标签: git

我正在尝试切换到我排除.gitignore第1行中所有内容的模式,然后包含我真正想要跟踪的文件。这是我的.gitignore文件:

*
!*.py
!README.md
!vizing.pdf
!Data*

我可以添加文件夹Data,但我真的想要Data及其所有子文件夹。当我尝试添加子文件夹时,会发生这种情况:

> git add Data/EdgeColoring
The following paths are ignored by one of your .gitignore files:
Data/EdgeColoring
Use -f if you really want to add them.

我尝试了this question的建议,但他们没有多大帮助。

> git check-ignore -v Data/EdgeColoring
.gitignore:1:*  Data/EdgeColoring

我无法找到带有*模式的另一个.gitignore文件,因此Data *似乎与Data / EdgeColoring不匹配。为什么是这样?什么是正确的模式?

1 个答案:

答案 0 :(得分:0)

按照git在回复中的建议,我添加了-f标志:

amber:IgnoreTest pjs$ touch Data/EdgeColoring/foo
amber:IgnoreTest pjs$ git status
On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)
amber:IgnoreTest pjs$ git add Data/EdgeColoring
The following paths are ignored by one of your .gitignore files:
Data/EdgeColoring
Use -f if you really want to add them.
amber:IgnoreTest pjs$ git add -f Data/EdgeColoring
amber:IgnoreTest pjs$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

    new file:   Data/EdgeColoring/foo

amber:IgnoreTest pjs$