Harry Moreno
Harry Moreno

Reputation: 11603

git remove file starting with a colon

I accidentally created a file named :w. I managed to delete it by using zsh tab feature. But I cannot remove it from my git cache.

    git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   Gemfile
#   modified:   Gemfile.lock
#   new file:   config/newrelic.yml
#
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   deleted:    :w
#

then

git rm :w
fatal: pathspec 'w' did not match any files

Upvotes: 10

Views: 2169

Answers (1)

Harry Moreno
Harry Moreno

Reputation: 11603

found the answer not 5 minutes later

git rm '\:w'

Upvotes: 14

Related Questions