git 忽略我的文件异常请求

git ignores my request for a file exception

我的 .gitignore 文件中有以下配置。

.idea/*
!.idea/inspectionProfiles/Teamcity.xml
!.idea/scopes/teamcity.xml
!.idea/runConfigurations/Watch_Sass_files.xml

应该忽略 .idea 目录中的所有文件,只有 3 个例外。它不允许我 git add 他们。我有 运行 git check-ignore,这就是消息

.gitignore:59:/.idea/* .idea/runConfigurations/Watch_Sass_files.xml

我什至在

您似乎可以设置目录例外但不能设置文件例外,例如 !.idea/runConfigurations/

这应该有效 — 忽略被 *:

忽略的目录
.idea/*
!.idea/inspectionProfiles/
!.idea/inspectionProfiles/Teamcity.xml
!.idea/scopes/
!.idea/scopes/teamcity.xml
!.idea/runConfigurations/
!.idea/runConfigurations/Watch_Sass_files.xml

可以简化为(忽略所有目录):

.idea/*
!.idea/*/
!.idea/inspectionProfiles/Teamcity.xml
!.idea/scopes/teamcity.xml
!.idea/runConfigurations/Watch_Sass_files.xml

很可能在您的 .gitignore 中发生了其他事情,无论您使用什么来查看和编辑它都没有向您显示。尾随白色 space(包括错误的行分隔符)、奇怪的字符集等等。

尝试 xxd -g8 -c32 .gitignore(或使用您选择的十六进制转储程序,这是我的)并找出您的编辑器显示给您的内容与每字节解码之间的差异。