Remove multiple deleted files in git

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!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store