.gitignore /folder vs folder/

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.


The latter would match "xxx/bin" and "bin" in any other subdirectories.

Answer for your edit: *.ext would take care of all files in the repository ending w/ that ext.


I tested the cases and also some more ones and here you can review the results:

Results

EDIT: Corrected according to @Dan Breen's comment below (thanks!)

Tags:

Git

Gitignore