【问题标题】:Upgrading Oh My Zsh gives me 'not a git repository' error升级 Oh My Zsh 时出现“不是 git 存储库”错误
【发布时间】:2016-02-02 20:50:36
【问题描述】:

由于我想更新 Oh My Zsh upgrade_oh_my_zsh 时将我的 OSX 升级到 El Capitan,因此出现以下错误:

Upgrading Oh My Zsh
fatal: Not a git repository (or any of the parent directories): .git
There was an error updating. Try again later?

我以前从未使用过 git,在互联网上搜索这个致命错误,他们建议在 /.oh-my-zsh 文件夹中执行 git init。运行此命令后,当我再次尝试运行 upgrade_oh_my_zsh 时,出现新的致命错误。

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists. 

我不知道它是否与它有关,但是当我打开终端(iTerm2)时,我也收到了这个通知:

/Users/peter/.zshrc:1: command not found: Path

任何人有这方面的经验或知道我的问题的解决方案吗?

【问题讨论】:

    标签: git oh-my-zsh


    【解决方案1】:

    看起来您的 git 存储库已从 oh-my-zsh 中删除?您可以通过运行重新添加远程并更新到最新版本的 Zsh:

    cd ~/.oh-my-zsh
    git init # you've already done this step, so you can skip
    git remote add origin https://github.com/robbyrussell/oh-my-zsh.git
    git fetch
    git reset --hard origin/master
    

    之后,重新启动您的终端实例,您应该一切顺利。

    【讨论】:

    • 感谢这工作!就在我完成最后一步时,我必须先删除--hard,然后再使用--hard
    • 没用。当我打开一个新的终端窗口时,我仍然收到错误
    【解决方案2】:

    上述解决方案对我不起作用。 我的问题是我有一个别名

    alias gpucb="git pull origin $(git branch --show-current)"

    我一发表评论,错误就消失了。 我需要解决这个问题。 另外,奇怪的是该错误仅在第二个git 命令中遇到。

    【讨论】:

    • 您的问题是命令$(git branch --show-current) 是在评估别名时执行的。要解决这个问题,您可以使用 `\` 转义 $
    • 或者用单引号包裹别名,好像也可以。
    猜你喜欢
    • 2015-08-31
    • 2020-08-19
    • 1970-01-01
    • 2013-07-30
    • 1970-01-01
    • 1970-01-01
    • 2017-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多