Files shown as deleted in the โModified but Not Updatedโ section of the state are deleted from the work tree, but not from the index. To perform a deletion in an index (i.e. remove a file from an index), you can do:
git diff -z --name-only --diff-filter=D | git update-index --remove -z --stdin
--diff-filter=D only shows the differences from the index, which is the deleted file, --name-only just prints its name, and -z uses NUL to separate file names, so you do not have to worry about file names with embedded characters new line. update-index then removes the data from the index.
If you have a version of xargs that supports -0 , you can make it a little easier:
git diff -z --name-only --diff-filter=D | xargs -0 git rm
Charles Bailey
source share