Git Glob Syntax: ignoring files everywhere or in a specific folder

I would like to exclude tracking .DS_Storefrom my folder and all subfolders . I also want to exclude the file .projectfrom my folder (but not from subfolders ).

What should I write in .gitignore (located in my folder)?

.DS_Store # or *.DS_Store ? I mean, is the asterisk necessary?
./.project # is this syntax correct?
+3
source share
1 answer

This should do the trick:

.DS_Store
/.project

When you provide the path to .gitignore, it applies it depending on where the .gitignore file is located (chroot if you want). Thus, / on the second line only means to ignore the file myfolder/.project.

+5
source

All Articles