How to do exception in .gitignore if I am using wildcards for folder path in ignore?

Viewed 142

I am aware this was asked here and answered, however no answer covers when the ignoring line uses wildcards...

I have the following line in .gitignore:

**/_secrets

Now I would like to add one exception to this using the ! syntax:

!**/_secrets/not_a_secret.txt

However this does not seem to work.

What I've tried:

!**/not_a_secret.txt
!**/_secrets/not_a_secret.txt
!(**/_secrets/not_a_secret.txt)

I've also tried to change **/_secrets to **/_secrets/ still does not work, all files in the _secrets folder are ignored, with no exception of not_a_secret.txt file.

What am I missing?

1 Answers
Related