Git无法访问github问题

一、背景

在使用git进行clone的时候,发现浏览器可以正常打开,而命令行却总是超时,怀疑是git代理的问题。于是尝试了各种办法后,终于通过设置git代理解决了。

如以下地址:GitHub - CocoaPods/Specs: The CocoaPods Master Repo,开发设备已经通过代理设置,浏览器可以正常访问github。但git命令行访问会出现如下错误:

致命错误:无法访问 'https://github.com/CocoaPods/Specs.git/':Failed to connect to github.com port 443 after 75047 ms: Couldn't connect to server

二、解决方法

通过git config进行设置,如下

git config --global https.proxy 'socks5://127.0.0.1:1086'
git config --global http.proxy 'socks5://127.0.0.1:1086'

再次执行依赖的安装如下

至此,解决了依赖下载慢或者超时问题。

三、其他

如果想把git的代理移除,执行如下操作

git config --global --unset https.proxy
git config --global --unset http.proxy

设置http代理

hongbozhao@bogon ~ % git config --global https.proxy 127.0.0.1:1087
hongbozhao@bogon ~ % git config --global http.proxy 127.0.0.1:1087 

指定某网址使用代理

#使用socks5代理(推荐)
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
#使用http代理(不推荐)
git config --global http.https://github.com.proxy http://127.0.0.1:1087
git config --global https.https://github.com.proxy https://127.0.0.1:1087

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

泓博

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值