This kind of whitelist is not easy in git.
Once you ignore the git directory, it will not look inside it and therefore will not check for exceptions inside that directory.
The only way around this is with long include / exclude cascades that are really ugly.
The best way is to think about your problem again and try to solve it without such general exceptions, for example, explicitly ignoring everything that you are sure you do not want.
source share