brew之加速

2021-01-21 14:42:00
CJL
轉貼:
Codsing-代碼演奏者
1818

有沒有齣現這種場景:使用brew install 安裝程序,一直卡在brew updating,這可能是使用著默認的github鏡像源導緻,那麽我們就需要將其切換到國內

 

1.鏡像切換(推薦中科大)

1)替換brew.git
cd "$(brew --repo)" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git //清華 或
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git //中科大 2)替換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 //清華 3)替換homebrew-cask 
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git 
4)替換homebrew-bottles: 
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile 
或 
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile 5)應用生效 brew update -v (查看過程)

 

2.鏡像複原

# 重置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

 

3. 問題修複

# 診斷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 
發錶評論
評論通過審核後顯示。
流量統計