.gitignore to ignore all files, then recursively allows files of a certain type
directory, git, recursion
Solution
You need to anchor your `*` otherwise it will continue to match all files even in un-ignored directories.
e.g.
/*
!.gitignore
!*.tt
!/Static/
Problem
I have a folder that is purely a T4 template folder but it outputs code generated files into other directories. So I'm looking to ignore everything except *.tt files (i.e. the *.cs, *.master, *.resx, etc.). There is one gotcha. I have a subfolder called static that contains files that should never be ignored. ``` /Test.tt /Test.cs /TestHtml.tt /TestHtml.html /Static /Sub/Sub.cs /Sub/Sub2/Sub2.cs /Sub3/Sub4/Sub5/Sub5.html ``` I only want to ignore the /Test.cs and /Test.html but include all other files. I've tried the following: /.gitignore ``` # Ignore all * # But not these files... !.gitignore !*.tt ``` /Static/.gitignore ``` !*.* #also have just tried blank ``` I can't get git to ignore the right things...main problem is the 'recursive exclude' I want for Static/..