我知道有很多关于如何忽略目录的问题,直到现在我通常没有遇到任何问题,但现在我卡在了一个我不理解的地方。
这是我的目录结构:
/src
/war
com.example.MyProject/
WEB-INF/
classes/
deploy/
lib/
我希望忽略以下目录的内容:
classes/
、deploy/
和 com.example.MyProject/
,这是我的 .gitignore 文件:*.log
war/WEB-INF/classes/
war/WEB-INF/deploy/
com.example.MyProject/
com.example.MyProject/
目录下的文件是自动生成的,git会忽略其中所有文件,除了一个名为com.example.MyProject.nocache.js
的文件。事实上,当我执行git status
时,会得到以下结果:
# On branch myBranch
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
# modified: .gitignore
# ......
# modified: war/com.example.MyProject/com.example.MyProject.nocache.js
为什么git拒绝忽略目录中的单个文件?我哪里做错了?