Reputation: 3199
I need to ignore all files except those ending in .php
, .css
, .html
or .js
.
This is what I have in my .gitignore file for now:
*
!.php
!/*.php
!*.php
It does ignore everything, but only permits .php
files in root directory, while hiding all the rest.
Upvotes: 28
Views: 12038
Reputation: 23
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.
Found in: https://stackoverflow.com/a/33983585/5388625
Upvotes: 2