git clean -n
only does a "dry-run" of git clean
to show you what it will delete, it doesn't actually delete anything. You can run the following sequence of commands to clean up your working copy and staging area/index:
git reset -- . # Clear the index/staging area
git checkout -- . # Revert changes in your working copy
git clean -df # Recursively delete untracked files.
If you want, you could even make these into a git alias:
# Make the alias
git config --global alias.undo \
"!git reset -- . ; git checkout -- . ; git clean -df; git status"
# Usage
git undo