gitignore all files (specific filetype) in a directory and subdirectories

git, gitignore

Solution

You can add something like this, it will work as of git 1.8.2.1 (documentation here)

A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.

# should work
master/xyz/**/*.xml

The first suggestion you posted won't work as it will not match anything (as it is a literal)

# wont work
master/xyz//.xml

Problem

What's the right way to ignore a certain filetype in a certain directory and all subdirectories in it? Example: ignore all `.xml` files in `master/xyz/` and all subdirectories in `master/xyz/`. I'm not sure which of the following two approaches is the right one... ``` master/xyz/*/*.xml master/xyz/**/*.xml ``` Which one should I use? (I use Git 1.9.1)

Original source

Related problems