n4opiq
Last Updated: February 25, 2016
·
731
· brendo

Quickly remove deleted files in preparation for a Git commit.

A familiar story, the uploads directory was added to the Git repo and over time the client has made a number of edits which has removed some of these files which were being tracked by Git.

How can you remove them all quickly so that you can commit this change?

You can't delete the entire folder, there are files that need to be kept. You could use git rm, but that would be time consuming to repeat for every single file.

Give this command a whirl, which will stage all deleted files ready for commit:

git ls-files --deleted | xargs git rm

You're welcome.

1 Response
Add your response

3722

Unless I'm missing the point wouldn't it be easier to use git add --all. It won't have quite the same results since it will stage all new, modified, and deleted files not just the deleted ones. But that's usually what I want.

over 1 year ago ·
Filed Under