更改源方法:(推荐)
http://mirrors.ustc.edu.cn/help/brew.git.html
https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
更改源方法:(淘汰)
cd $(brew --repo)
git remote -v
# origin https://github.com/Homebrew/brew (fetch)
# origin https://github.com/Homebrew/brew (push)
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
git remote -v
# origin https://mirrors.aliyun.com/homebrew/brew.git (fetch)
# origin https://mirrors.aliyun.com/homebrew/brew.git (push)
cd $(brew --repo)/Library/Taps/homebrew/homebrew-core
git remote -v
# origin https://github.com/Homebrew/homebrew-core (fetch)
# origin https://github.com/Homebrew/homebrew-core (push)
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
git remote -v
# origin https://mirrors.aliyun.com/homebrew/homebrew-core.git (fetch)
# origin https://mirrors.aliyun.com/homebrew/homebrew-core.git (push)
brew update
# Already up-to-date.
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
恢复默认配置:
# 重置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
然后删掉 HOMEBREW_BOTTLE_DOMAIN 环境变量,将你终端文件。
vi ~/. zshrc
删除
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles
运行
source ~/.zshrc
那么介绍一下常用的命令:
brew –help #查看brew的帮助
brew install git #安装git软件
brew install --cask cakebrew #安装UI界面的软件
brew uninstall git #卸载git软件
brew search git #搜索git软件
brew list #显示已经安装软件列表
brew list python3 #显示已安装软件的安装路径
brew update #更新索引,把所有的Formula目录更新,并且会对本机已经安装并有更新的软件用*标明。
brew upgrade git #更新Git软件
brew upgrade #更新所有旧软件
brew [info | home] [FORMULA…] #查看软件信息
brew cleanup -n #查看可清理的旧版本,不执行实际操作。
brew cleanup git #清理指定包(Git)的旧版本
brew cleanup #清理所有包的老旧版本
brew cleanup --prune=all #缓存清理,brew下载的所有安装包(/Users/zhanglei/Library/Caches/Homebrew)
brew outdated #查看那些已安装的程序需要更新
brew home * #用浏览器打开
brew info * #显示软件内容信息
brew deps * #显示包依赖(如:brew deps pango --tree)
brew prune #清理无效项
brew config #查看brew配置
brew unlink php@7.4 #删除软链接
brew link php@8.1 #新建软链接
brew link --overwrite php@8.1 #强制新建软链接--overwrite是强制的意思
brew services list #可以查看当前已管理的服务,并且可看到启动状态。
brew services cleanup #清除已卸载无用的启动配置文件。
锁定不想更新的包
brew pin php56 # 锁定某个包
brew unpin php56 # 取消锁定
brew info # 显示安装了包数量,文件数量,和总占用空间
brew deps --installed --tree # 查看已安装的包的依赖,树形显示
完整卸载一个brew安装的软件,包裹其依赖.
使用brew uninstall git卸载软件只会卸载软件本身而不会同时卸载其依赖包,使用以下命令可完全卸载,并且不会影响到其他软件。
第一步:brew tap beeftornado/rmtree
第二步:brew rmtree git
第三步:brew cleanup
卸载Homebrew方法:(未验证转载)
cd `brew --prefix`
rm -rf Cellar
brew prune
rm `git ls-files`
rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
rm -rf .git
rm -rf ~/Library/Caches/Homebrew