When you specify to ignore * , Git will not return to any subdirectories (even if you have a "unignore" template that may correspond to something inside one of the directories).
There is little gitignore template that can help. The trailing slash makes the template apply only to directories. So you should be able to use this:
In the demo below, I use the above .gitignore and have an additional file (named do-not-keep ) next to each .keep file. You can see that it works for several levels of subdirectories and does not display other files. You will need to organize for each directory your own .keep (or any other) through some independent method.
% git status --short -uall ?? a/.keep ?? a/b/.keep ?? a/b/c/.keep ?? a/b/c/d/.keep ?? e/.keep ?? e/f/.keep ?? e/f/g/.keep ?? h/.keep ?? h/i/.keep ?? j/.keep
This was done with Git 1.7.3.1, but I expect it to work for other versions as well.
Demo setup:
% git init % mkdir -pa/b/c/de/f/gh/ij % zargs -i.. -- **/*(/) -- touch ../.keep ../do-not-keep % tree -aI .git . . |-- .gitignore |-- a | |-- .keep | |-- b | | |-- .keep | | |-- c | | | |-- .keep | | | |-- d | | | | |-- .keep | | | | `-- do-not-keep | | | `-- do-not-keep | | `-- do-not-keep | `-- do-not-keep |-- e | |-- .keep | |-- do-not-keep | `-- f | |-- .keep | |-- do-not-keep | `-- g | |-- .keep | `-- do-not-keep |-- h | |-- .keep | |-- do-not-keep | `-- i | |-- .keep | `-- do-not-keep `-- j |-- .keep `-- do-not-keep 10 directories, 21 files
Chris johnsen
source share