替換中科大源
替換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
替換Homebrew Bottles源: 參考:替換Homebrew Bottles源
對於bash用戶:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
對於zsh用戶
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
替換清華源 清華源設置參考
替換現有上游
# brew 程序本身,Homebrew/Linuxbrew 相同
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 以下針對 mac OS 系統上的 Homebrew
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
git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git
# 更換后測試工作是否正常
brew update
復原
(感謝Snowonion Lee提供說明)
# brew 程序本身,Homebrew/Linuxbrew 相同
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
# 以下針對 mac OS 系統上的 Homebrew
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://github.com/Homebrew/homebrew-cask-fonts.git
git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://github.com/Homebrew/homebrew-cask-drivers.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
注釋掉bash配置文件里的有關Homebrew Bottles即可恢復官方源。 重啟bash或讓bash重讀配置文件。
Brew更新
更新Homebrew自己
brew update
查看哪些安裝包要更新
brew outdated
更新包
brew upgrade
brew upgrade $FORMULA #更新指定的包
清理舊版本
brew cleanup #清理所有包的舊版本
brew cleanup $FORMULA #清理指定包的舊版本
brew cleanup -n #查看可清理的舊版本包,不執行實際操作
鎖定不想更新的包
brew pin $FORMULA #鎖定某個包
brew unpin $FORMULA #取消鎖定
查看安裝包的相關信息
brew info $FORMULA #顯示某個包的信息
brew info #顯示安裝了包數量,文件數量,和總占用空間
brew deps --installed --tree #查看已安裝的包的依賴,樹形顯示
查看已安裝的包
brew list
刪除
brew rm $FORMULA #刪除某個包
brew uninstall --force $FORMULA #刪除所有版本
下面一句話搞定brew更新
brew update && brew upgrade && brew cleanup
brew upgrade $(brew list | awk '{print $1}' | xargs)
Homebrew-Cask更新
brew cask list
brew cask outdated #列出需要更新的軟件
brew call $FORMULA
brew cask uninstall $FORMULA
brew cask install --force <outdated-cask> #更新軟件
brew cask upgrade $FORMULA #更新軟件
下面一句話搞定cask更新
brew cask upgrade $(brew cask list | awk '{print $1}' | xargs)