There\'s already several questions similar to this, but none of the answers work for me.
I want to ignore everything in the folders below my repository except files
Your problem is that the /*
pattern at the beginning is matching all files and directories at the top level - including testdir
, so everything inside testdir
is ignored.
This is what you want:
# Ignore everything
*
# Don't ignore directories, so we can recurse into them
!*/
# Don't ignore .gitignore and *.foo files
!.gitignore
!*.foo
When you do a git add .
with this config, you should find you have only .gitignore
and *.foo
files listed as changes to be committed.