Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.