Does Git have a whitelist functionality?

git

Solution

Per help from @amalbala's comment, this is how I can achieve what i want:

.gitignore

# first ignore everything
*

# then don't ignore the root directory
!*/

# now whitelist the particular directories and all files within them
!DirAA/*
!DirAC/*

This will result in everything being ignored, BUT `DirAA/` and `DirAC/`.

Problem

Git has the `.gitignore` file which is for a blacklist on excluded files/folders. Is there an adversary function to this? Here is my use case. ``` BigDir/ DirAA/ DirAB/ DirAC/ DirAD/ DirAE/ ..... ``` Is there a way to just say "allow only these directories?" (a whitelist) Maybe something like... .gitkeep ``` DirAA/ DirAC/ ``` which would result in All other directories BUT `DirAA` and `DirAC` to be ignored. I would just add each other directory to the `.gitignore` but these folders keep growing, and I wouldn't want to keep adding each new folder.

Original source

Related problems