升级 Oh My Zsh 时出现 'not a git repository' 错误

Upgrading Oh My Zsh gives me 'not a git repository' error

因为我想更新 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 中删除?您可以通过 运行:

重新添加远程并更新到最新版本的 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

之后,重新启动您的终端实例,您就可以开始了。

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

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

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

我刚遇到那条消息。就我而言(在 Mac 上)恰好我刚刚安装了 Xcode,而 git 在我接受其条款和条件之前停止工作。以防万一...