MacOS、Git 的代理配置

4,019 阅读1分钟

MacOS命令行代理配置

设置代理

export http_proxy=socks5://127.0.0.1:1080 # 配置http 代理访问
export https_proxy=socks5://127.0.0.1:1080 # 配置https 代理访问
export all_proxy=socks5://127.0.0.1:1080 # 配置http和https访问

取消代理

unset http_proxy # 取消http 代理访问
unset https_proxy # 取消https 代理访问

Git 配置代理,用于解决拉取失败或拉取太慢的问题

我们在拉取国外的 Git 托管平台时,可能会因为跨国际网络或中国长城的因素,导致拉取失败,这个情况下,如果你具有自己的 HTTP 代理 或 Socket5 代理服务器,可以通过给本地的 Git 工具配置代理,使用代理服务器去优化网络连接。

相关命令

HTTP 代理

git config --global https.proxy http://127.0.0.1:10800
git config --global https.proxy https://127.0.0.1:10800

SOCKET5 代理

git config --global http.proxy 'socks5://127.0.0.1:1086'
git config --global https.proxy 'socks5://127.0.0.1:1086'

查看代理配置

git config --global --list

删除代理配置

git config --global --unset http.proxy
git config --global --unset https.proxy