【GitHub无法拉取远程仓库】fatal: unable to access ‘https://github.com/***/***.git’:Failed to connect github.com

问题描述问题描述

好久不用一台设备进行开发了,cmd拉取远程仓库,怎么都无法拉取到,git命令报错如下:

D:\IdeaProjects\XXX>git pull
fatal: unable to access 'https://github.com/XXX/XXX.git/': Failed to connect to github.com port 443 after 21095 ms: Couldn't connect to server

解决方法

感觉是网络配置原因造成的,git可能需要搭梯子或者长期不用,需要重新配置一下,看看终端是否ping通,重新配置一下本地代理。

#重新配置一下默认代理接口
git config --global http.proxy "127.0.0.1:xxxx" # XXXX为代理端口号
git config --global https.proxy "127.0.0.1:xxxx"

接下来试着先ping 一下github.com

D:\IdeaProjects\XXX>ping github.com
正在 Ping github.com [xx.xxx.xxx.xxx] 具有 32 字节的数据:
来自 xx.xxx.xxx.xxx 的回复: 字节=32 时间=96ms TTL=113
来自 xx.xxx.xxx.xxx 的回复: 字节=32 时间=96ms TTL=113
来自 xx.xxx.xxx.xxx 的回复: 字节=32 时间=96ms TTL=113
来自 xx.xxx.xxx.xxx 的回复: 字节=32 时间=96ms TTL=113

xx.xxx.xxx.xxx 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 96ms,最长 = 96ms,平均 = 96ms

可以,直接进行clone

D:\IdeaProjects\XXX>git pull
Already up to date.

但是我在没配置之前ping都ping不通就很奇怪,ping命令和git配置有什么关系,有懂得可以评论区留言

还原代理配置

可以使用以下命令去除git 代理

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

一站式 AI 云服务平台

更多推荐