Git Ignoring Files and Folders Ignoring a file in any directory


Example

To ignore a file foo.txt in any directory you should just write its name:

foo.txt # matches all files 'foo.txt' in any directory

If you want to ignore the file only in part of the tree, you can specify the subdirectories of a specific directory with ** pattern:

bar/**/foo.txt # matches all files 'foo.txt' in 'bar' and all subdirectories

Or you can create a .gitignore file in the bar/ directory. Equivalent to the previous example would be creating file bar/.gitignore with these contents:

foo.txt # matches all files 'foo.txt' in any directory under bar/