Search code examples
gitgitignore

.gitignore /folder vs folder/


in .gitignore what is the difference between using

/bin

and

bin/

And how would I make it so that it removes a certain file, no matter where it is?

*/*.ext

Solution

  • A leading / anchors the ignore pattern at the point in the tree where the particular .gitignore resides.

    A trailing / means that a pattern will only match a directory (and so all the files in that matching directory).

    You can have both, e.g. /bin/ will match only a directory called bin and only at the level of the .gitignore file.

    A simple *.ext will match any file ending with .ext anywhere at or below the level of the .gitignore file in which it appears.