Git remove deleted files
Sometimes I forget to delete files in a git repository using git rm, leaving lots of deleted files in Changes not staged for commit.
I can still use git rm <deleted file name> to stage the deletion. But what if I have dozens of files to delete? Not to say I may mistype the file names since shell cannot tab-complete names of deleted files.
- Use
git rmdirectly. This may not work on Windows.
git rm $(git ls-files --deleted)
- Use
xargsto pass parameters togit rm. This works perfectly on both *nix and Windows.
git ls-files --deleted -z | xargs -0 git rmWritten by Mikkkee
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#