1

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
Omar Yasser
  • 135
  • 1
  • 5

1 Answers1

2

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.

phd
  • 82,685
  • 13
  • 120
  • 165
  • You are right! Unfortunately, I didn't notice that because I added the file to git first and in a later commit, I added the .gitignore line. – Omar Yasser Dec 15 '21 at 16:51
  • @OmarYasser If you want to ignore it: `git rm -r --cached tanafaso-frontend/blob/master/lib/net/api_interface/azkar && git commit -m "Remove azkar"` : https://stackoverflow.com/q/1274057/7976758 – phd Dec 15 '21 at 16:53