Rene Zammit
Rene Zammit

Reputation: 101

Git delete a file with space in name

I have added a file and also committed webpageone fresh.rhtml. I left a space in the name. When I a try to remove it, using:

git rm -f /webpageone fresh.rhtml

I get this error:

pathspec '/webpageone' did not match any files.

I tried removing another file and it worked... So the problem is the spacing. How can I remove this?

Upvotes: 9

Views: 11629

Answers (2)

Daniel Melendrez
Daniel Melendrez

Reputation: 424

Just in case someone finds this thread after nearly 12 years, the way that it works now is:

git rm -r 'File name'/Folder/*.*

using apostrophes for the file name with spaces.

Upvotes: 0

Marcin Koziński
Marcin Koziński

Reputation: 11044

That's a shell problem, not a git problem. You need to escape the space. This should work:

git rm -f /webpageone\ fresh.rhtml

I guess this should also work:

git rm -f "/webpageone fresh.rhtml"

Upvotes: 19

Related Questions