I accidentally added a lot of temporary files using git add -A
I managed to unstage the files using the following commands and managed to remove the dirty index.
git ls-files -z | xargs -0 rm -f
git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached
The above commands are listed in the git help rm. But sadly, my files were also deleted on execution, even though I had given the cache option. How can I clear the index without losing the content?
Also, it would be helpful if someone can explain the way this pipe operation works.