Instead of matching files to ignore, ignore all and then exclude the few files which need to be tracked in version control.