Search code examples
gitgitignore

.gitignore a file extension, but not a directory name


I have the following entry in .gitignore.

*.meta

Now this would be fine if only files would end in .meta.
Unfortunately, I have a directory /ProtoBuf.Meta/.
And now the entire content of ProtoBuf.Meta is ignored...

Is there a way to tell git that this gitignore directive is only for files, not directories ?


Solution

  • Try this one

    *.meta[!/]
    

    or

    !.meta/*
    

    "!" negates the pattern