[oh-my-zsh] Can‘t update: not a git repository. 错误解决

问题

MacOS打开iTerm总是出现[oh-my-zsh] Can't update: not a git repository.

解决方法

# 网上的解决方法
# 不推荐
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

也就是卸载CLT再重装,但耗时太长且并没有解决问题,无奈只能到Apple官网再重新下载CLT,这样速度快一点

https://developer.apple.com/download/all/?q=Command%20Line%20Tools

之后运行(如果你没有卸载CLT,可直接跳到这一步)

cd $ZSH
git remote set-url origin "https://github.com/ohmyzsh/ohmyzsh.git"

如果出现错误:error: No such remote 'origin'

再运行:

git init
git remote add origin "https://github.com/ohmyzsh/ohmyzsh.git"
git config --global url."https://github.com/".insteadOf git://github.com/

之后如果每次打开iTerm总是提醒你要不要更新,则运行

sudo vim ~/.zshrc

按 进入编辑模式,在末尾添加

DISABLE_AUTO_UPDATE="true"
DISABLE_UPDATE_PROMPT="true"

按 esc 退出编辑模式,键入 :wq 保存退出,最后运行

source ~/.zshrc

猜你喜欢

转载自blog.csdn.net/weixin_44231433/article/details/127086139