opposite of .gitignore file? [duplicate]

You can include !-lines to whitelist files: a .gitignore with:

*
!included/

will exclude all, but the 'included/' directory

Note that if you want files matching a pattern to be un-ignored, in subdirectories, you will need to prevent the containing directories from getting ignored too. This should not pose a large problem, since git doesn't actually track directories, only files (identified by a repository path).

Example:

*
!*/
!SOURCES

will ignore everything, except SOURCES in subdirectories.


You can use .gitignore for that.

*
!file0.txt
!file1.txt

In a case where you interested in file0.txt and file1.txt.