git针对指定网站设置代理

我们经常要用到各种git地址,比如github、gitee还有自己搭建的git等等。


但是github我们经常拉取和推送代码的时候超时,这时候如果我们搜索会发现大量的文章都是告诉我们设置全局系统代理:

#使用http代理 
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy https://127.0.0.1:7890
#使用socks5代理
git config --global http.proxy socks5://127.0.0.1:7891
git config --global https.proxy socks5://127.0.0.1:7891

这种方式会让我们所有的git请求都走代理,但是我们访问gitee肯定不需要代理啊,走代理反而会慢。

所以我们需要针对github单独设置代理。


我们可以这么干。

#使用socks5代理(推荐)
git config --global http.https://github.com.proxy socks5://127.0.0.1:7891
git config --global https.https://github.com.proxy socks5://127.0.0.1:7891
#使用http代理(不推荐)
git config --global http.https://github.com.proxy http://127.0.0.1:7890
git config --global https.https://github.com.proxy https://127.0.0.1:7890

这样就会只有网址是https://github.com的时候走我们指定的git代理,剩下的不走,完美解决了我们的问题。


如果我们要取消使用代理,可以设置

git config --global --unset http.proxy 
git config --global --unset https.proxy
posted @   jvx  阅读(1111)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示