Reputation: 75
I have a gitignore file that excludes a source directory, except for some specific files:
/src_app
!/src_app/Learning\ Module\-darwin\-x64/
!/src_app/assets/icons/mac/
The exclude-from-ignore the Learning Modules directory is the same regular expression as the one to exclude-from-ignore the icons directory, except I'm escaping the whitespaces in the Learning Modules directory, while the icons directory doesn't need that.
The weird thing is that all of the files under the Learning Module directory are being recognized, whereas no files under the icons directory are being picked up.
What is the difference between these two patterns that makes git recognize one sub-path while not the other?
Upvotes: 0
Views: 624
Reputation: 489828
The key is that src_app/assets
is not being read at all so that src_app/assets/icons
is never found. Not being found, it cannot be un-ignored so that it will be scanned to find /src_app/assets/icons/mac
so that this can be un-ignored.
The fix is to first un-ignore src_app/assets
, then also un-ignore src_app/assets/icons
:
!src_app/assets/
!src_app/assets/icons/
The first of these makes Git look inside src_app/assets
(so that it will find icons
) and the second makes Git look inside src_app/assets/icons
once it finds that. The existing rules for src_app/assets/icons/mac
will then take effect.
(If there are files within src_app/assets/
and/or src_app/assets/icons/
that should not be automatically added and should not be complained-about as untracked, you will have to list those as to-be-ignored.)
Side note: in /src_app/Learning\ Module\-darwin\-x64/
, the backslashes before the hyphens are unnecessary (but harmless). None of these are regular expressions; they are all glob patterns.
Upvotes: 1