MacOs如何解决brew update卡住问题
方法:临时切换国内镜像源
1. 使用环境变量临时切换源
你可以通过设置环境变量来临时指定 Homebrew 使用国内镜像源,而不会影响全局配置。
运行以下命令:
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git" export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
然后执行 brew update
:
brew update
完成后,这些环境变量只会在当前终端会话中生效,关闭终端后会自动恢复为默认配置。