Home > Blockchain >  git check-ignore outputting unignored files
git check-ignore outputting unignored files

Time:12-16

The file https://github.com/tanafaso/tanafaso-frontend/blob/master/lib/net/api_interface/azkar/requests/get_categories_response.dart is not ignored by git, and that's expected as I have only listed azkar/ in .gitignore which means that only the directory azkar/ under the root should be ignored.

However, git check-ignore thinks that the file will be ignored and that it satisfies the pattern 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

CodePudding user response:

From 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.

Nothing is said about directory level unlike

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…

Hence the pattern azkar/ matches any directory "azkar" deep in the directory hierarchy.

  • Related