Search code examples
gitgitignore

gitignore - Ignore all file types except specified ones


I only want to commit files which extension is .fmb, .fmx and .pll, but I can't configure .gitignore file to achieve this.

I've tried with the following:

!.fmb
!.fmx
!.pll

and also with:

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

but it doesn't work.


Solution

  • Try this in your gitignore file-

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

    You will want to first ignore everything and then whitelist files.