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 rm
directly. This may not work on Windows.
git rm $(git ls-files --deleted)
- Use
xargs
to pass parameters togit rm
. This works perfectly on both *nix and Windows.
git ls-files --deleted -z | xargs -0 git rm
Written 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#