opposite of .gitignore file?

Git

Git Problem Overview


> Possible Duplicate:
> Make .gitignore ignore everything except a few files

Is it possible to let git ignore all files by default, unless specified in a special file?

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

You can use .gitignore for that.

*
!file0.txt
!file1.txt

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmorpheusView Question on Stackoverflow
Solution 1 - GitseheView Answer on Stackoverflow
Solution 2 - GittamasdView Answer on Stackoverflow