【问题标题】:How to use git rm -cached to remove tilde file如何使用 git rm -cached 删除波浪号文件
【发布时间】:2017-03-06 12:34:21
【问题描述】:

我的 git 存储库中有 ~$itial Problem Description.docx 文件。

我猜它是 Microsoft word 的恢复类型文件。

我把它添加到了repo中,不小心推送了。

当我尝试做 git rm --cached ~$itial Problem Description.docx 它说 - '~ Problem Description.docx' 没有匹配任何文件

我如何git rm --cached 这个?我应该在我的.gitignore 中输入什么来忽略它?

【问题讨论】:

  • 你试过 git -rm --cached '~$itia Problem Description.docx' 吗?
  • 添加 *~ 到你的 .gitignore
  • 添加 ~* 到你的 .gitignore

标签: git version-control gitlab


【解决方案1】:

问题是由于$,shell 将$itial 解释为(空)环境变量。您可以通过使用单引号来防止 shell 解析它:

$ git rm '~$itial Problem Description.docx' 

【讨论】:

  • 我正在使用zsh,这正是问题所在。
猜你喜欢
  • 2014-05-02
  • 2017-12-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-16
  • 2023-03-09
  • 2011-06-28
  • 2012-09-17
相关资源
最近更新 更多