I have one directory tree with many kind of different files. There are 300 directories on the parent directory. Each directory could have other sub directories.
I only want to track *.cocci on all sub directories. Here is my .gitignore:
*
!*.cocci
But it do not work, as the files on sub directories are not tracked. How can I tell git that I only want to track *.cocci on all sub directories?
Read this question.
You want:
# Blacklist everything
*
# Whitelist all directories
!*/
# Whitelist the file you're interested in.
!*.cocci
Note, this'll track only *.cocci
files. Yours doesn't work because you ignore everything (that's the first line), which ignores all subdirectories.