Search code examples
gitgitignoreglob

Ignore partial filename only if in specific directory


I wish to ignore:

settings/local_*.py
apps/settings/local_*.py
path_to/settings/local_*.py

But I don't wish to ignore:

local_*.py
something/else/local_*.py

And also I don't wish to ignore:

settings/non_local_*.py
...

Is this beyond gitignore?

Of course, I'm looking for a generic solution that will work no matter where the settings directory is located (within the repo).


Solution

  • Ah, I stabbed at the solution!

    settings/local_*.py won't work.

    But this will: **/settings/local_*.py!