【笔记】Git配置代理

前言

Git配置和取消代理

http代理

1
2
git config --global http.proxy "http://127.0.0.1:8080"
git config --global https.proxy "http://127.0.0.1:8080"

socks5代理

1
2
git config --global http.proxy "socks5://127.0.0.1:1080"
git config --global https.proxy "socks5://127.0.0.1:1080"

取消代理

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

ssh形式

  • 修改或创建~/.ssh/config配置文件
1
2
3
4
5
6
7
8
# 必须是 github.com
Host github.com
HostName github.com
User git
# 走 HTTP 代理
# ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=8080
# 走 socks5 代理(如 Shadowsocks)
# ProxyCommand nc -v -x 127.0.0.1:1080 %h %p

完成

参考文献

GitHub——chuyik