Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git, ignore folder except for some files with certain extension

I have a folder named packages in my git repo, I want to ignore everything inside that folder except for files with targets extension. I've tried this in my gitignore:

packages/
!packages/**/*.targets

but it doesn't work.

How do I ignore that folder but not the targets files?

like image 348
Escobar5 Avatar asked Jul 09 '13 19:07

Escobar5


1 Answers

This seems to work for me (Git 1.8.2.1):

packages/**/*.*
!packages/**/*.targets

I needed the *.* part, otherwise ** matches 0 directories, and a lone * at the end will match any directory inside packages, practically ignoring every directory, and any file inside.

I hope the *.* is not too bad for you, but having files without extension is pretty uncommon.

like image 123
yonosoytu Avatar answered Nov 07 '22 04:11

yonosoytu