mac Homebrew 安装 设置国内源 和 git安装 CocoaPods

更新时间:2023-05-25 21:55

苹果电脑 极速安装脚本(精简版 几秒钟安装完成):

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" speed

切换中科大国内源:(两行两行的复制....)

# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# 替换homebrew-cask.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

# 应用生效
brew update
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

git安装:

brew install git

使用 vi 打开 .gitconfig 文件:

vi ~/.gitconfig

写入下列配置(建议在最末写入):
 

[http]
    proxy = socks5://127.0.0.1:10808
    proxy = http://127.0.0.1:10809
[https]
    proxy = socks5://127.0.0.1:10808
    proxy = https://127.0.0.1:10809


 

修改后重启 git ,使配置生效:

git config -l --global

查看当前代理:

git config -l

安装CocoaPods:

  • 查找默认源

    gem sources
    
  • 移除默认源 添加新源

  • # 添加镜像源并移除默认源. 或者 https://mirrors.tuna.tsinghua.edu.cn/rubygems/
    gem sources --add https://mirrors.aliyun.com/rubygems/ --remove https://rubygems.org/
    # 列出已有源
    gem sources -l
    # 应该只有镜像源一个

安装cocoapods:
 

sudo gem install -n /usr/local/bin cocoapods

pod setup

Homebrew国内如何自动安装(国内地址) - 知乎 (zhihu.com)
Homebrew切换为国内镜像源 - zetaiota - 博客园 (cnblogs.com)