HOMEBREW镜像源

268 阅读2分钟

1.1 查看当前镜像源的信息

# 查看brew镜像源
git -C "$(brew --repo)" remote -v

# 查看homebrew-core镜像源
git -C "$(brew --repo homebrew/core)" remote -v

# 查看homebrew-cask镜像源(需要安装后才能查看)
git -C "$(brew --repo homebrew/cask)" remote -v 

执行 brew 命令安装应用的时候,跟以下 3 个仓库地址有关。

brew.git (源代码仓库) homebrew-core.git (核心软件仓库) homebrew-bottles (预编译二进制软件包)

1.2 修改为中科大镜像源

# 修改brew镜像源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# 修改homebrew-core镜像源
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# 修改homebrew-cask镜像源(需要安装后才能修改)
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

# 更新
brew update

或者

# 进到目录,更改镜像源
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# 进到目录,更改镜像源
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# 修改.bash_profile配置信息,并使文件生效
source ~/.base_profile

# 测试更新
brew update

参考地址:lug.ustc.edu.cn/wiki/mirror…

1.3 修改为阿里云镜像源

cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
 
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# 别忘记更新配置文件,并生效配置文件
source ~/.base_profile

# 测试更新
brew update

1.4 清华大学镜像源

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

# 别忘记更新配置文件,并生效配置文件
source ~/.base_profile

# 测试更新
brew update

参考地址:mirrors.tuna.tsinghua.edu.cn/help/homebr…

1.5恢复默认设置镜像源

# 恢复brew镜像源
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git


# 恢复homebrew-core镜像源
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git

# 恢复homebrew-cask镜像源(需要安装后才能修改)
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

brew update

1.6 更改配置文件

### aliyun io
# export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles

### 中科大 io
# export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

### 清华大学 io
# export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

1.7 brew 常用命令

命令	说明	
brew –help	#查看brew的帮助    	
brew install git	#安装git软件	
brew uninstall git	#卸载git软件	
brew search git	#搜索git软件	
brew list	#显示已经安装软件列表	
brew update	#更新软件,把所有的Formula目录更新,并且会对本机已经安装并有更新的软件用*标明。	
brew upgrade git	#更新某具体软件	
brew [info|home] [FORMULA…]	#查看软件信息	
brew cleanup git	#单个软件删除,和upgrade一样	
brew cleanup	#删除所有	
brew outdated	#查看那些已安装的程序需要更新	
brew home *	#用浏览器打开	
brew info *	#显示软件内容信息	
brew deps *	#显示包依赖	
brew config	#查看brew配置