Mac下安装homebrew

1. 下载

https://raw.githubusercontent.com/Homebrew/install/master/install.sh
文件,保存在电脑上,假设名字为 install.txt

2.修改默认镜像源

用文本编辑器修改一下内容

BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
CORE_TAP_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"

3.终端运行

/bin/bash install.txt

4.出现以下问题时:

==> Tapping homebrew/core
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

5.把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

6.安装成功

brew update后,终端会显示Already up-to-date.到此,homebrew就安装成功