git undo alias with xargs
- by ABach
I have a git alias (git undo) that undoes everything in the working directory, including new files, changed files, and deleted files:
!git reset --hard && git ls-files -d | xargs -0 git rm --ignore-unmatch && git clean -fq
On OS X, this works great. On Linux, however, I run into the following issue: if no files have been deleted from the repository, the git ls-files -d | xargs -0 git rm --ignore-unmatch command will fail (xargs will be passed nothing).
Is there a way to have xargs silently move on if it receives nothing from git ls-files?