Git设置代理
文章目录

Git设置代理
有时会国内会因为github克隆速度非常慢,中途各种错误断开造成克隆项目失败,可以尝试设置代理解决,配合科学上网使用
全局代理
# HTTP代理
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
# socks代理
git config --global http.proxy socks5://127.0.0.1:1086
git config --global https.proxy socks5://127.0.0.1:1086这里可以打开SS查看代理设置,查看自己的端口是否为1080,不是的改为对应的端口。
只对GitHub进行代理
如果挂了全局代理,克隆coding之类的国内仓库会变慢,所以我建议使用如下命令,只对GitHub进行代理,对国内的仓库不影响。
# HTTP代理
git config --global http.https://github.com.proxy https://127.0.0.1:1080
git config --global https.https://github.com.proxy https://127.0.0.1:1080
# socks代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
git config --global https.https://github.com.proxy socks5://127.0.0.1:1086注意:以上两点都是对https协议进行代理设置,也就是仅对git clone https://www.github.com/xxxx/xxxx.git这种命令有效。对于SSH协议,也就是git clone git@github.com:xxxxxx/xxxxxx.git这种,依旧是无效的。
取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy查看已有配置
git config --global -l本文标题:Git设置代理
本文链接:https://blog.luola.me/30.html
除非另有说明,本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议。
声明:转载请注明文章来源。