How to git rm a file whose name starts with ':'

git

Solution

You need to escape the `:` (and not just in your shell, but for `git` itself):

git rm '\:web,'

or

git rm \\:web,

Alternatively, you could use the `:`-based pathspec that the error is telling you about. For example:

git rm :::web,

Problem

I've accidentally got a file in my repo named `:web,`. When typing `git rm :web,` it seems to think the colon is a part of a command and not the start of a filename: ``` fatal: pathspec 'web,' did not match any files ``` Quotes don't make a difference.

Original source