How can I ignore all files except those with a certain extension in git?
For those, who would like to include file extensions which are located in subdirs like @jmborr and @Racso
# .gitignore for excluding all but certain files in certain subdirs*!*.cfg!/**/!certain/subdir/i_want_to_include/*.cfg
when you exclude everything ('*'), you have to white-list folders ('/**/'), before being able to white-list files.