【问题标题】:git remove file starting with a colongit 删除以冒号开头的文件
【发布时间】:2013-10-04 05:42:39
【问题描述】:

我不小心创建了一个名为 :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
#

然后

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

【问题讨论】:

  • 你试过了吗:git rm --cached -r .??
  • 哈!感谢您提出这个问题和答案。让我猜猜,你使用 Vim 并以某种方式输入了“:w”,然后可能脑子有点走神,你又输入了“:w”。我认为这将花费我超过 1 分钟(我可能会添加不到 5 分钟!)它需要您找到解决方案。

标签: git unix filenames


【解决方案1】:

不到 5 分钟就找到了答案

git rm '\:w'

【讨论】:

  • 也适用于以其他无用字符开头,例如破折号。
猜你喜欢
  • 1970-01-01
  • 2020-10-31
  • 2016-07-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-26
  • 2013-12-18
相关资源
最近更新 更多