Try to ignore files but re-include folders:
/**/* of the first rule: it ignores all files and folders recursively, then re-include folders
!/**/ in the second rule).
Then you can re-include files (because their folders are not ignored)
The main rule about
So ignoring files and folders (with '
/**/*') means you won't be able re-include files unless their parent folders are themselves re-included (with
!/**/: trailing slash means 'folders').
/dir_2/**/* !/dir2/**/ !/dir_2/**/*.xlsx
Note that you don't have to commit a
.gitignore to test its effect: modify it, and do a
git status: as long as those files where not tracked (do a
git rm -r --cached dir_2 first), the effect of those rules will be immediate.
.gitignore in place, do a
git add ., and a
git status: it should only show
dir_2/ as being added.