【问题标题】:How did I break git?我是如何破坏 git 的?
【发布时间】:2022-08-18 18:59:36
【问题描述】:

我以为我已经复制了我想检查 git diff 的文件路径,但不小心在我的剪贴板中出现了 \"quit()\" 并匆忙返回。所以我不小心跑了

(base) user@MacBook-Air sage % git diff quit()
function> 
function> 

现在,在 git 中似乎没有任何工作。例如:

(base) user@MacBook-Air sage % git diff HEAD
git:5: command not found: quit
(base) user@MacBook-Air sage % git status
git:6: command not found: quit
(base) user@MacBook-Air sage % git diff  
git:7: command not found: quit
(base) user@MacBook-Air sage % git log
git:8: command not found: quit
(base) user@MacBook-Air sage % git branch --list
git:9: command not found: quit

有谁知道我做了什么来得到这个?此外,您知道如何解决它吗?我在这个分支上的所有更改都已提交,但尚未在远程分支上。

我试图谷歌如何重置 git,但这只是让我得到了git reset 的结果。

  • 您是否尝试过启动一个新的外壳?

标签: git function zsh


【解决方案1】:

它与 git 无关。你的 shell 认为你在看到这个() 后开始定义一个函数,并等待函数体的定义。 git 成为函数名。之后当你调用 git 时,它会运行你定义的函数而不是真正的 git。

【讨论】:

  • 具体来说,这是一个 zsh 的东西; bash 会给出语法错误,但 zsh 定义了两个函数,git 和 diff。
  • @torek 是的,我后来意识到了同样的事情。它发生在 zsh 而不是 bash 上。也许这是一个错误...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-03-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-27
  • 2011-09-11
  • 2013-08-17
相关资源
最近更新 更多