Changing data/*
to data/
is not usable for me, because after that you can't whitelist files/folders in excluded folders.
when you put this in .gitignore
data/
!data/foo.txt
the file foo.txt
won't be included.
To remove all untracked files (and folders) as they are shown in git status
(and keep something like data/*
in gitignore) you can use
git ls-files -z -o --exclude-standard | xargs -0 rm -rf
This will list all untracked files and pass them to rm -rf
function, which will delete them.
Credits to https://stackoverflow.com/a/3801554/4710968