Impossible to git rm with special characters

2.6k views Asked by At

I added files in my git repository that I want to remove now. I deleted it with rm XXX. Now, git status shows me:

Changed but not updated:
    deleted:    "Sche\314\201ma application + interface.graffle"

No matter how I git rm it, I still have a :

fatal: pathspec 'Schêma application + interface.graffle' did not match any files

I tried to escape whitespaces with \, to escape \ with \\, to escape " with \". No matter what I tried, it failed.

Do you have hints?

3

There are 3 answers

0
Geo On BEST ANSWER

This will detect the remove:

git add -u
0
Adam Dymitruk On

try git gui. You could probably escape it properly but it might be too much trouble than it's worth. It should escape this properly.

If your issue is staging removals, just git add -A to add all changes to the index.

0
ario On

Wrap it in single quotes.

 git rm '"Sche\314\201ma application + interface.graffle"'

If you need to escape single quotes in a file name, wrap those in double quotes. So if for some reason your file name is '" (that's single quote, double quote), use

git rm "'"'"'

where the first set of double quotes is wrapping the single quote, and the end set of single quotes is wrapping the double quote.

This is for Bash in general, not just git. More on quote insanity here: How to escape single-quotes within single-quoted strings?