John Smith John Smith - 1 month ago 5
Git Question

Git ignore only files with the same name as folder

I have this directory structure:

app/.bundle/
app/file1.bundle
app/tmp/file2.bundle
app/.gitignore


I would like to add an entry in .gitignore that only ignores files that ends with .bundle.

Doing
*.bundle
will also ignore the folder
.bundle
, but I want it checked in along with the contents.

Answer

You can do this:

*.bundle
!.bundle/

This will ignore everything that ends with .bundle, except a folder that is called .bundle.