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

git, gitignore, glob

Solution

This should do the trick:

.DS_Store
/.project

When you a provide a path to .gitignore, it applies it based on where the .gitignore file is (a chroot, if you will). So the / on the second line means only ignore the `myfolder/.project` file.

Problem

I would like to exclude `.DS_Store` tracking from myfolder and all subfolders. I also want to exclude a `.project` file from myfolder (but not from its subfolders). What should I write in .gitignore (situated in myfolder)? ``` .DS_Store # or *.DS_Store ? I mean, is the asterisk necessary? ./.project # is this syntax correct? ```

Original source