Gitignore正在忽略我要跟踪的目录

Gitignore正在忽略我要跟踪的目录,git,Git,我正在尝试切换到一种模式,即排除.gitignore第1行中的所有内容,然后包括我真正想要跟踪的文件。这是我的.gitignore文件: * !*.py !README.md !vizing.pdf !Data* 我可以添加文件夹数据,但我确实需要数据及其所有子文件夹。当我尝试添加子文件夹时,会发生以下情况: > git add Data/EdgeColoring The following paths are ignored by one of your .gitignore file

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

*
!*.py
!README.md
!vizing.pdf
!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.
我试着采纳这些建议,但没有多大帮助

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

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

按照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$
amber:IgnoreTest pjs$touch Data/EdgeColoring/foo
琥珀色:忽略测试pjs$git状态
论分行行长
初始提交
无需提交(创建/复制文件并使用“git add”跟踪)
琥珀色:忽略测试pjs$git添加数据/edgeColor
以下路径被一个.gitignore文件忽略:
数据/边缘颜色
如果确实要添加它们,请使用-f。
琥珀色:忽略测试pjs$git add-f数据/边缘颜色
琥珀色:忽略测试pjs$git状态
论分行行长
初始提交
要提交的更改:
(使用“git rm--cached…”取消存储)
新文件:Data/EdgeColoring/foo
琥珀色:忽略测试pjs$

Git的ignore系统在您只忽略想要忽略的内容时效果最佳。你试图用另一种方式做事有什么原因吗?使用前缀
取消一个以前被一般规则忽略的模式。这正是我的思维方式。谢谢,我也使用了-f。不过,我想让git自动跟踪Data/及其子文件夹中的所有文件。