美文网首页
homebrew重置

homebrew重置

作者: Leoeoo | 来源:发表于2021-05-11 10:33 被阅读0次
如果折腾了很久都不好使,想把homebrew恢复到初始状态,可以尝试使用如下方案:
# 诊断Homebrew的问题:
$ brew doctor

# 重置brew.git设置:
$ cd "$(brew --repo)"
$ git fetch
$ git reset --hard origin/master

# homebrew-core.git同理:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git fetch
$ git reset --hard origin/master

# 应用生效:
$ brew update  
如果使用brew doctor诊断时提示:
no such file or directory: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

可能是下载homebrew失败了,只需要执行:

# 进入目录
$ cd /usr/local/Homebrew/Library/Taps
# 创建目录
$ mkdir homebrew
# 进入目录
$ cd homebrew
# 使用中科大源先把homebrew-core下载下来。
$ git clone https://mirrors.ustc.edu.cn/homebrew-core.git

# 以下步骤可设置可不设置
# 替换brew.git:
$ cd "$(brew --repo)"
# 中科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# 替换homebrew-core.git:
# 中科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# 应用生效:
$ brew update
重置更新源(换回官方源)
# 重置brew.git:
$ cd "$(brew --repo)"
$ git remote set-url origin https://github.com/Homebrew/brew.git

# 重置homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git

# 应用生效:
$ brew update
替换源
# 替换brew.git:
$ cd "$(brew --repo)"
# 中科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 清华大学:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 替换homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
# 中科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 清华大学:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

# 替换homebrew-bottles:
# 中科大:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
# 清华大学:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 应用生效:
$ brew update

完成更新源的更换后,我们可以使用

brew upgrade

将现有的软件进行更新至最新版本,这样便能很直接的看出速度上的变化了。
最后不要忘记

brew cleanup

将旧有的软件安装包进行清理

中科大开源软件镜像站
清华大学开源软件镜像站

原文:https://www.jianshu.com/p/b26c7bc14440

相关文章

网友评论

      本文标题:homebrew重置

      本文链接:https://www.haomeiwen.com/subject/xusgdltx.html