有時會國內(nèi)會因為github克隆速度非常慢,中途各種錯誤斷開造成克隆項目失敗,可以嘗試設(shè)置代理解決
設(shè)置代理
1.http || https協(xié)議
//設(shè)置全局代理
//http
git config --global https.proxy http://127.0.0.1:1080
//https
git config --global https.proxy https://127.0.0.1:1080
//使用socks5代理的 例如ss,ssr 1080是windows下ss的默認(rèn)代理端口,mac下不同,或者有自定義的,根據(jù)自己的改
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
//只對github.com使用代理,其他倉庫不走代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global https.https://github.com.proxy socks5://127.0.0.1:1080
//取消github代理
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy
//取消全局代理
git config --global --unset http.proxy
git config --global --unset https.proxy
2.SSH協(xié)議
//對于使用git@協(xié)議的,可以配置socks5代理
//在~/.ssh/config 文件后面添加幾行,沒有可以新建一個
//socks5
Host github.com
User git
ProxyCommand connect -S 127.0.0.1:1080 %h %p
//http || https
Host github.com
User git
ProxyCommand connect -H 127.0.0.1:1080 %h %p