Mac 下 brew 切換為國(guó)內(nèi)源
Mac 下brew 切換為國(guó)內(nèi)源
簡(jiǎn)介
Homebrew 是一款自由及開(kāi)放源代碼的軟件包管理系統(tǒng),用以簡(jiǎn)化macOS 和linux 系統(tǒng)上的軟件安裝過(guò)程。它擁有安裝、卸載、更新、查看、搜索等很多實(shí)用的功能,通過(guò)簡(jiǎn)單的一條指令,就可以實(shí)現(xiàn)包管理,十分方便快捷。
Homebrew 主要有四個(gè)部分組成: brew、homebrew-core 、homebrew-bottles、homebrew-cask。
|
名稱(chēng) |
說(shuō)明 |
|
brew |
Homebrew 源代碼倉(cāng)庫(kù) |
|
homebrew-core |
Homebrew 核心軟件倉(cāng)庫(kù) |
|
homebrew-bottles |
Homebrew 預(yù)編譯二進(jìn)制軟件包 |
|
homebrew-cask |
提供 macOS 應(yīng)用和大型二進(jìn)制文件 |
替換為阿里源
# 查看brew.git 當(dāng)前源
$ cd"$(brew --repo)"&& git remote -v
origin https://github.com/Homebrew/brew.git (fetch)
origin https://github.com/Homebrew/brew.git (push)
# 查看homebrew-core.git 當(dāng)前源
$ cd"$(brew --repo homebrew/core)"&& git remote -v
origin https://github.com/Homebrew/homebrew-core.git (fetch)
origin https://github.com/Homebrew/homebrew-core.git (push)
# 修改brew.git 為阿里源
$ git -C "$(brew --repo)"remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 修改homebrew-core.git 為阿里源
$ git -C "$(brew --repo homebrew/core)"remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# zsh 替換brew bintray 鏡像
$ echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles'>> ~/.zshrc
$ source~/.zshrc
# bash 替換brew bintray 鏡像
$ echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles'>> ~/.bash_profile
$ source~/.bash_profile
# 刷新源
$ brew update
替換為清華源
# 替換各個(gè)源
$ git -C "$(brew --repo)"remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
$ git -C "$(brew --repo homebrew/core)"remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
$ git -C "$(brew --repo homebrew/cask)"remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
# zsh 替換brew bintray 鏡像
$ echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles'>> ~/.zshrc
$ source~/.zshrc
# bash 替換brew bintray 鏡像
$ echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles'>> ~/.bash_profile
$ source~/.bash_profile
# 刷新源
$ brew update
替換為中科大源
# 替換各個(gè)源
$ git -C "$(brew --repo)"remote set-url origin https://mirrors.ustc.edu.cn/brew.git
$ git -C "$(brew --repo homebrew/core)"remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
$ git -C "$(brew --repo homebrew/cask)"remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# zsh 替換brew bintray 鏡像
$ echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles'>> ~/.zshrc
$ source~/.zshrc
# bash 替換brew bintray 鏡像
$ echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles'>> ~/.bash_profile
$ source~/.bash_profile
# 刷新源
$ brew update
騰訊云的官方鏡像源:
替換方式為:
替換brew.git:
cd"$(brew --repo)"
git remote set-url origin https://mirrors.cloud.tencent.com/homebrew/brew.git
替換homebrew-core.git:
cd"$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.cloud.tencent.com/homebrew/homebrew-core.git
更新bottles源
對(duì)于bash用戶(hù):
echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.cloud.tencent.com/homebrew-bottles'>> ~/.bash_profile
source~/.bash_profile
對(duì)于zsh用戶(hù)
echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.cloud.tencent.com/homebrew-bottles'>> ~/.zshrc
source~/.zshrc
重置為官方源
# 重置brew.git 為官方源
$ git -C "$(brew --repo)"remote set-url origin https://github.com/Homebrew/brew.git
# 重置homebrew-core.git 為官方源
$ git -C "$(brew --repo homebrew/core)"remote set-url origin https://github.com/Homebrew/homebrew-core.git
# 重置homebrew-cask.git 為官方源
$ git -C "$(brew --repo homebrew/cask)"remote set-url origin https://github.com/Homebrew/homebrew-cask
# zsh 注釋掉HOMEBREW_BOTTLE_DOMAIN 配置
$ vi ~/.zshrc
# export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx
# bash 注釋掉HOMEBREW_BOTTLE_DOMAIN 配置
$ vi ~/.bash_profile
# export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx
# 刷新源
$ brew update

浙公網(wǎng)安備 33010602011771號(hào)