Search code examples
gitgitignore

What is the difference between /* and / and the very end of a path on .gitignore?


On some .gitignore files we may see:

somedirectory/*

or

somedirectory/

Does this means the first will match recursively while the second one, only that directory ?


Solution

  • The later matches the directory, but ignoring directory means ignoring all its contents. So it is recursive.

    For the former, the * will only match immediate entries. But since it will match directories as well, and ignoring a directory means ignoring all its contents, it's also recursive.

    Git does not track directories; a directory whose all content is ignored is as good as ignored.

    Therefore there is no practical difference.