Here is how to detect deleted files and stage their deletion as part of the next commit. All the solutions on this thread have different merits. This solution bellow specifically deals with the problem of file names with spaces in them.
git status --porcelain | awk '/^.D .*$/ {print $0}' | sed 's/.D \(.*\)/\1/' | tr -d '"' | xargs -I {} git rm '{}'
make sure you test this with git's --dry-run option before running it with the following:
git status --porcelain | awk '/^.D .*$/ {print $0}' | sed 's/.D \(.*\)/\1/' | tr -d '"' | xargs -I {} git rm --dry-run '{}'
explanation:
git status --porcelain
This prints out something like D "/path to a folder/path to a file" which happens only when there are spaces in the path names
awk '/^.D .*$/ {print $0}'
match only lines that start with " D "
sed 's/ D \(.*\)/\1/'
remove " D " from the front of each string
tr -d '"'
remove quotes, if any
xargs -I {} git rm '{}'
define file name variables as {} run file name under git rm enclosed in single quotes in order to make sure that it supports file names with spaces.