Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git删除以冒号开头的文件_Git_Unix_Filenames - Fatal编程技术网

git删除以冒号开头的文件

git删除以冒号开头的文件,git,unix,filenames,Git,Unix,Filenames,我意外地创建了一个名为:w的文件。我通过使用zsh选项卡功能成功地删除了它。但我无法将其从git缓存中删除 git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: Gemfile # modified: Gemfile.lock # new file: config/new

我意外地创建了一个名为
:w
的文件。我通过使用zsh选项卡功能成功地删除了它。但我无法将其从git缓存中删除

    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
#

不到5分钟就找到了答案

git rm '\:w'

您是否尝试过:
git-rm--cached-r.
?哈!谢谢你的提问和回答。让我猜猜,你使用Vim,不知怎么地键入“:w”,然后可能思维有点混乱,你又键入了“:w”。我想这会花费我超过1分钟的时间(这种方式也适用于从其他无用的角色开始,比如破折号)。
git rm '\:w'