Git-设置全局代理
目录
Git 设置全局代理
Git 设置全局代理或项目代理
git config
:
全局配置,设置git代理服务器
# 设置 HTTP 代理
git config --global http.proxy http://127.0.0.1:7897
# 设置 HTTPS 代理
git config --global https.proxy http://127.0.0.1:7897
# 设置所有协议的代理(如果需要)
git config --global core.gitProxy 'socks5://127.0.0.1:7897'
如果想仅仅在当前项目配置,需要去掉 --global
:
# 设置 HTTP 代理(仅当前项目)
git config http.proxy http://127.0.0.1:7897
# 设置 HTTPS 代理(仅当前项目)
git config https.proxy http://127.0.0.1:7897
# 设置所有协议的代理(仅当前项目)
git config core.gitProxy 'socks5://127.0.0.1:7897'
测试延迟:
ping -c 5 github.com
取消设置
git config --global --unset-all http.proxy
git config --global --unset-all https.proxy