homebrew 切换国内镜像 清华镜像

首次安装 Homebrew

首先,下载安装脚本的镜像(也可以直接从官方下载,即 https://raw.githubusercontent.com/Homebrew/install/master/install.sh )

git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git
cd install

并编辑其中的 install.sh

BREW_REPO="https://github.com/Homebrew/brew"
# 改成:
BREW_REPO="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"

接着,运行 install.sh 以安装 Homebrew

出现如下代码时,不用等了,直接关掉命令窗口

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...

进入下面的 Taps 目录,clone homebrew-core

cd /usr/local/Homebrew/Library/Taps/homebrew

git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

把homebrew repo切换为清华镜像

cd "$(brew --repo)"
 
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
 
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
 
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
 
brew update

这时,终端会显示Already up-to-date.到此,homebrew就安装完毕了。

  

  

  

  

  

原文地址:https://www.cnblogs.com/ihuangjianxin/p/14194114.html