update Homebrew 太慢,更換Homebrew的更新源
阿新 • • 發佈:2020-08-12
update Homebrew 太慢,更換Homebrew的更新源
42019.03.01 11:13:54字數 214閱讀 23,184更新源的選擇
預設官方的更新源都是存放在GitHub上的,這也是中國大陸使用者訪問緩慢的原因,一般來說我們會更傾向選擇國內提供的更新源,在此推薦中國科大以及清華大學提供的更新源。
替換更新源
# 替換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
如果你之前折騰過不少導致你的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.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 upgrade
$ brew cleanup
將舊有的軟體安裝包進行清理
43人點贊
iOS開發技巧