很多时候我们在使用github的时候会出现下载很慢的情况,如果你使用代理,会提高下载和上传速度
克隆 repo 的两种方式:https 和 ssh 方式
ssh 方式:git clone git@github.com:xxx/git.git
https 方式:git clone https://github.com/xxx/git.git
https 方式克隆的 repo,走 http 或 sock5 代理,任选一个
查看代理设置
git config --global http.proxy
git config --global https.proxy
git config --global -l
设置http/https全局代理
git config --global http.proxy http://127.0.0.1:1087
git config --global https.proxy http://127.0.0.1:1087
设置Socks5全局代理
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
ssh 克隆方式的代理设置,直接在全局设置文件配置,即 ~/.ssh/config 文件
HostName github.com
User git
# 走 HTTP 代理,需要 brew install socat
# ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=1087
# 走 socks5 代理(如 Shadow~socks)
ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
# 走 socks5 代理(如 Shadow~socks),Windows 平台没有 nc 命令
# ProxyCommand connect -S 127.0.0.1:1086 %h %p
删除全局代理
git config --global --unset http.proxy
git config --global --unset https.proxy
个人代理服务器设置
git config –global http.proxy http://proxyuser:proxypwd@proxy.server.com:port
只对github.com使用代理,其他仓库不走代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
取消github代理
git config --global --unset http.https://github.com.proxy