Git 克隆问题排查与解决方案

ops/2025/3/15 10:45:16/

问题 1:克隆时无法连接 GitHub

Cloning into 'OpenManus'... fatal: unable to access 'https://github.com/mannaandpoem/OpenManus.git/': Failed to connect to github.com port 443 after 21074 ms: Could not connect to server 克隆项目时

错误表明无法连接到 github.com 的 443 端口(HTTPS),超时约 21 秒。可能原因包括网络问题、防火墙限制或 GitHub 服务器状态。建议:

  1. 检查网络连接,尝试访问 https://github.com。

  2. 验证仓库地址是否正确。

  3. 检查 GitHub 状态:GitHub Status。

  4. 测试其他网络或使用 SSH:

    bash

    收起自动换行复制

    git clone git@github.com:mannaandpoem/OpenManus.git

  5. 调整 Git 配置或使用 curl -v 调试。


问题 2:如何为 Git 配置代理

我使用了代理,git应该如何配置代理

Git 支持通过 http.proxy 和 https.proxy 配置代理。步骤如下:

  1. 确认代理信息:例如 http://proxy.example.com:8080。

  2. 全局配置

    git config --global http.proxy http://proxy.example.com:8080 git config --global https.proxy http://proxy.example.com:8080

    • 带用户名密码:

      git config --global http.proxy http://user:pass@proxy.example.com:8080

    • SOCKS5 代理:

      git config --global http.proxy socks5://proxy.example.com:1080

  3. 单次命令

    git clone -c http.proxy=http://proxy.example.com:8080 https://github.com/mannaandpoem/OpenManus.git

  4. 环境变量

    export http_proxy=http://proxy.example.com:8080 export https_proxy=http://proxy.example.com:8080

  5. 验证

    git config --global --get http.proxy


问题 3:不设置代理会怎样

如果不设置代理

不设置代理时,Git 直接通过本地网络连接 github.com:

  • 如果网络无限制,克隆应成功。

  • 如果网络屏蔽 GitHub(常见于受限地区),会失败。 建议:

  1. 测试网络:ping github.com 和 curl https://github.com。

  2. 清除代理:

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

  3. 尝试 SSH:

    git clone git@github.com:mannaandpoem/OpenManus.git

  4. 修改 hosts 文件(临时绕过):

    140.82.121.3 github.com


问题 4:再次尝试克隆仍失败

$ git clone https://github.com/mannaandpoem/OpenManus.git Cloning into 'OpenManus'... fatal: unable to access 'https://github.com/mannaandpoem/OpenManus.git/': Failed to connect to github.com port 443 after 21059 ms: Could not connect to server 我都没有设置代理

确认未设置代理,但仍无法连接 443 端口。建议:

  1. 测试网络:

    ping github.com curl -v https://github.com

  2. 检查代理残留:

    git config --global --get http.proxy

  3. 使用 SSH(需配置密钥):

    ssh-keygen -t rsa -b 4096 -C "你的邮箱" git clone git@github.com:mannaandpoem/OpenManus.git

  4. 切换网络测试。


问题 5:Ping 测试结果

ping github.com 正在 Ping github.com [20.205.243.166] 具有 32 字节的数据: 来自 20.205.243.166 的回复: 字节=32 时间=185ms TTL=112 来自 20.205.243.166 的回复: 字节=32 时间=101ms TTL=112 来自 20.205.243.166 的回复: 字节=32 时间=138ms TTL=112 来自 20.205.243.166 的回复: 字节=32 时间=164ms TTL=112 20.205.243.166 的 Ping 统计信息:    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失), 往返行程的估计时间(以毫秒为单位):    最短 = 101ms,最长 = 185ms,平均 = 147ms

Ping 成功,说明网络可达 20.205.243.166,但 HTTPS(443 端口)可能被阻断。建议:

  1. 测试 HTTPS:

    curl -v https://github.com

  2. 检查本地防火墙。

  3. 再次尝试克隆或使用 SSH。


问题 6:Curl 测试结果

curl -v https://github.com * Host github.com:443 was resolved. * IPv6: (none) * IPv4: 20.205.243.166 *   Trying 20.205.243.166:443... * connect to 20.205.243.166 port 443 from 0.0.0.0 port 1113 failed: Timed out * Failed to connect to github.com port 443 after 21115 ms: Could not connect to server * closing connection #0 curl: (28) Failed to connect to github.com port 443 after 21115 ms: Could not connect to server是不是

域名解析成功,但 443 端口连接超时,确认网络屏蔽 HTTPS 流量。解决方案:

  1. 使用代理

    git config --global http.proxy http://127.0.0.1:1111 git config --global https.proxy http://127.0.0.1:111 git clone https://github.com/mannaandpoem/OpenManus.git

  2. 使用 SSH

    git clone git@github.com:mannaandpoem/OpenManus.git

  3. 切换网络。

  4. 修改 hosts(效果有限)。


总结

用户无法直接通过 HTTPS 克隆 GitHub 仓库,原因是网络屏蔽了 443 端口流量。Ping 成功但 HTTPS 失败表明限制针对特定端口。推荐解决方案:

  • 配置代理(需提供代理信息)。

  • 使用 SSH(需配置密钥)。

  • 切换无限制网络。


http://www.ppmy.cn/ops/165918.html

相关文章

Zookeeper相关面试题

以下是150道Zookeeper相关面试题: Zookeeper基础概念 1. Zookeeper是什么? Zookeeper是一个开源的分布式协调服务,用于管理分布式系统中的配置、命名、分布式锁等功能。 2. Zookeeper的主要功能有哪些? • 配置管理 • 分布式…

【3D视觉学习笔记2】摄像机的标定、畸变的建模、2D/3D变换

本系列笔记是北邮鲁老师三维重建课程笔记,视频可在B站找到。 1. 摄像机的标定 摄像机标定的过程就是从1张或者多张图片中求解相机的内外参数的过程。 根据上一节的知识,针孔摄像机模型的世界坐标系到成像平面的映射关系为 p K [ R , T ] P p K[R,T]…

C#通过API接口返回流式响应内容---分块编码方式

1、背景 上一篇文章《C#通过API接口返回流式响应内容—SSE方式》阐述了通过SSE(Server Send Event)方式,由服务器端推送数据到浏览器。本篇是通过分块编码的方式实现 2、效果 3、具体代码 3.1 API端实现 [HttpGet] public async Task Chu…

基于YOLOv8深度学习的PCB缺陷检测识别系统【python源码+GUI界面+数据集+训练代码】

目录 一、界面功能展示 二、前言摘要 三、GUI界面演示 (一)用户加载自定义模型 (二)单张图像检测 (三)检测图像文件夹 (四)检测视频 (五)保存 四、模…

Docker 构建 nginx-redis-alpine 项目详解

Docker 构建 nginx-redis-alpine 项目详解 一、课程概述 嘿,朋友们!今天咱们要深入探索一个超级实用的项目 ——nginx-redis-alpine!这个项目可不简单,它包含了好多重要的知识点,像文件目录结构、核心文件的作用及配…

什么是海外仓WMS系统?跟ERP系统有什么区别?

近年来,随着数字化技术的升级,越来越多的海外仓引入了WMS系统来支持仓库管理。那么,什么是海外仓WMS系统?它和我们常说的ERP系统有什么区别?海外仓使用WMS系统又有哪些好处呢?本篇文章将为你解答清楚。 一…

《探秘人工智能与鸿蒙系统集成开发的硬件基石》

在科技飞速发展的当下,人工智能与鸿蒙系统的集成开发开辟了创新的前沿领域。这一融合不仅代表着技术的演进,更预示着智能设备生态的全新变革。而在这场技术盛宴的背后,坚实的硬件配置是确保开发顺利进行的关键,它就像一座大厦的基…

织梦Dedecms站内搜索指定搜索或隐藏搜索栏目方法

Dedecms搜索原代码 <form name"formsearch" action"{dede:global.cfg_cmsurl/}/plus/search.php"> <div class"form"><h4>搜索</h4><input type"hidden" name"kwtype" value"0" /&g…