Remove multiple deleted files in git
Nov 26, 2020
Sometimes when you are committing changes in git you’ll find that a number of files have been deleted.
You could manually set these files to delete by individually issuing the command:
git rm filename
However, there is a shortcut. If you issue the command:
git ls-files --deleted
It will return a list of all files that are flagged as deleted.
You can then simply pass that list to git rm, using a combined syntax like this:
git rm $(git ls-files --deleted)
Just don’t forget the--deleted
parameter!