Git代理,用于解决clone GitHub代码慢的问题

v*2*ra--y的http/https协议不支持GitHub的代理,会报Proxy CONNECT aborted这个错,但是socks5是可以的,所以让Git的代理走socks5协议(需要在Github上添加自己的公钥),在C:UsersAdministrator.gitconfig内配置如下(仅代理Github,其他的git操作不走代理):

[http "https://github.com"]
    proxy = socks5://127.0.0.1:1082

或者单次代理:

-c http.proxy="socks5://127.0.0.1:1082"

s*s时候clone时可以走http协议,增加下面参数即可:

-c http.proxy="127.0.0.1:1081"

 参考(下面命令设置与在.gitconfig文件中设置效果一样):

// 全局设置
git config --global https.proxy http://127.0.0.1:1082
git config --global https.proxy https://127.0.0.1:1082
git config --global http.proxy 'socks5://127.0.0.1:1082'
git config --global https.proxy 'socks5://127.0.0.1:1082'

// 针对某个domain设置
git config --global http.https://github.com.proxy socks5://127.0.0.1:1082
git config --global https.https://github.com.proxy socks5://127.0.0.1:1082
git config --global http.https://github.com.proxy https://127.0.0.1:1082
git config --global https.https://github.com.proxy https://127.0.0.1:1082

 参考:https://struggleblog.com/2018/07/13/accelerate_github_clone/

原文地址:https://www.cnblogs.com/dreamroute/p/12917581.html