I'm using this simple git alias

    rmdel = "!git rm $(git ls-files -d)"

meant "remove deleted", i.e. to remove from the staging area all files deleted from the file system. It works fine except when there are any files containing blanks. Then obviously the list gets split on them as well leading to file names of non-existing files.

I think it should be possible to solve it using IFS, but IFS doesn't seem to work in cygwin and I doubt that something like

    rmdel = "!IFS=' ' git rm $(git ls-files -d)"`

could work at all. Any better idea?

1 Answer 1


ls-files has a switch designed for this purpose, -z:

-z    \0 line termination on output.

xargs has a switch to let you separate input items by a null character instead of whitespace, -0. Combining them, you get:

$ git ls-files -dz | xargs -0 git rm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .