git: Delete all tracked files?

For files you might want to change your command line slightly to the suggested command-line on the git-rm page

git ls-files -z | xargs -0 rm -f

This is much safer with more complex file paths. For directories you could try a similar strategy:

git ls-tree --name-only -d -r -z HEAD | sort -rz | xargs -0 rmdir 

It does however depend on how you would like to treat directories that contain files (often gitignored) that are untracked. The command line above should leave these files and their directories.

But it would be easy to change this to delete the directory, whatever the contents.