使用.gitignore忽略文件夹?

Hai*_*ood 23 git directory gitignore

可能重复:
忽略Windows上Git repos中的目录

我有几个文件夹,缓存分散在整个webapp中.

我正在用Git跟踪这个项目.

我已将空的index.html文件添加到每个缓存文件夹中.

我想忽略cache文件夹的所有内容,但默认情况下文件夹是空的,因此index.html的原因.

我试过了

*cache/*
!*cache/index.html
Run Code Online (Sandbox Code Playgroud)

但它并没有忽视它们.