tiimgreen / github-cheat-sheet

A list of cool features of Git and GitHub.
http://git.io/sheet
MIT License
47.5k stars 5.26k forks source link

Shell and whitespace in file names #166

Closed weissi closed 7 years ago

weissi commented 7 years ago

$ git rm $(git ls-files -d) is quite dangerous. You might accidentally delete other files if one of the files deleted in git contains whitespace in the file name.

Better:

$ git ls-files -d | while read f; do rm "$f"; done

That'll work better (still has issues with files containing new line characters but that's a lot less likely to happen).

tiimgreen commented 7 years ago

Could you put this in a PR?