git check-ignore 输出未忽略的文件

git check-ignore outputting unignored files

文件 https://github.com/tanafaso/tanafaso-frontend/blob/master/lib/net/api_interface/azkar/requests/get_categories_response.dart 没有被 git 忽略,这是预期的,因为我只在 .gitignore 中列出了 azkar/,这意味着只有目录 azkar/根目录下应该忽略。

但是,git check-ignore 认为该文件将被忽略并且它满足模式 azkar/

➜  azkar-frontend git:(master) ✗ git check-ignore --verbose lib/net/api_interface/azkar/requests/get_categories_response.dart
.gitignore:20:azkar/    lib/net/api_interface/azkar/requests/get_categories_response.dart

来自 https://git-scm.com/docs/gitignore#_pattern_format :

If there is a separator at the end of the pattern then the pattern will only match directories, otherwise the pattern can match both files and directories.

不同,目录级别没有任何说明

If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore…

因此模式 azkar/ 匹配目录层次结构深处的任何目录“azkar”。