Gitignore - ignore all file types except those specified

I only want to commit files with the extension .fmb , .fmx and .pll , but I can not configure the .gitignore file for this.

I tried the following:

 !.fmb !.fmx !.pll 

as well as with:

 !*.fmb !*.fmx !*.pll 

but that will not work.

+6
source share
2 answers

Try this in the gitignore- file

* !*.fmb !*.fmx !*.pll

You must ignore everything first, and then whitelists.

+5
source

The only rule to keep in mind when working with gitignore rules gitignore :

Cannot re-include the file if the parent directory of this file is excluded ( * )
( * : if certain conditions are not met in git 2.?, see below)

Since ' * ' also ignores folders, any file exclusion rule will not work.

Try:

 * !*/ !*.fmb !*.fmx !*.pll 

This will correctly ignore folders ( !*/ ) And allow the following exclusion rule for working with files.


Please note that with git 2.9.x / 2.10 (in the middle of 2016?) It is possible to re-enable the file if the parent directory of this file is excluded if there is no template added in the path .

Nguyễn Thái Ngọc Duy ( pclouds ) is trying to add this feature:

However, since one of the conditions for re-inclusion was:

Part of the catalog in the re-inclusion rules must be literal (i.e. without wildcards)

In any case, this would not work.

+4
source

All Articles