Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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.

like image 623
Archonic Avatar asked Jan 18 '26 16:01

Archonic


1 Answers

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,
like image 167
Carl Norum Avatar answered Jan 20 '26 14:01

Carl Norum