Homebrew

更换和重置Mac Homebrew的默认源

2019-04-25  本文已影响0人  夜行的鸟

Homebrew作为Mac os系统的包管理器,给软件的安装和更新等带来了极大地便利,但使用过程中总会遇到软件下载特别慢的问题,通过将默认源更改为国内的镜像地址,可以极大地提高下载速度。下面是收集的一些最新的更改默认源的操作(在终端里执行代码):

更换为清华源

更换brew.git

cd "$(brew --repo)"
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.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

更换Home Bottles源

长期更换:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

临时更换:
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

更换为中科大源

更换brew.git

cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/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

更换Home cask软件仓库

cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

更换Home Bottles源

长期更换:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

临时更换:
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

重置默认源

重置brew.git

cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

重置核心软件仓库

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

重置Homebrew cask软件仓库

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

重置Homebrew Bottles源

注释掉bash配置文件里的有关Homebrew Bottles即可恢复官方源。 重启bash或让bash重读配置文件。

参考

清华Homebrew 镜像使用帮助
中科大Homebrew 源使用帮助

上一篇 下一篇

猜你喜欢

热点阅读