ubantu20.04 git clone 无法连接问题与解决方法
因为有代理工具,所以和最后使用配置git代理后成功下载。
如果使用 git clone https://github.com/xuankuzcr/rpg_vikit.git
无法访问,可能是网络连接问题或仓库访问权限导致的。可以尝试以下解决方法:
-
检查网络连接
确保你的网络可以正常访问 GitHub。可以尝试 ping GitHub 服务器:ping github.com
如果无法 ping 通,可能是网络限制(如防火墙、代理设置)导致,需检查网络环境或切换网络。
-
使用 SSH 协议克隆(推荐)
如果 HTTPS 协议被屏蔽,可尝试 SSH 协议。首先确保已配置 GitHub SSH 密钥(参考 GitHub 官方文档),然后使用以下命令:git clone git@github.com:xuankuzcr/rpg_vikit.git
-
检查仓库是否存在
确认仓库 URL 正确,可直接在浏览器中访问https://github.com/xuankuzcr/rpg_vikit.git
,查看是否存在该仓库。如果页面显示 404,可能是仓库已删除或名称拼写错误。 -
使用代理(如适用)
若网络需要代理才能访问 GitHub,可配置 Git 代理:# 设置 HTTP 代理(替换为你的代理地址和端口) git config --global http.proxy http://127.0.0.1:1080 git config --global https.proxy https://127.0.0.1:1080# 取消代理(如需) git config --global --unset http.proxy git config --global --unset https.proxy
-
手动下载仓库
如果以上方法均无效,可直接在浏览器中访问仓库地址,通过 GitHub 页面的 “Code” 按钮下载 ZIP 压缩包,解压后使用。
如果问题持续,可能是仓库本身的访问权限限制(如私有仓库),此时需要联系仓库所有者获取访问权限。
lihongli@lhl:~/catkin_ws/src$ git clone https://github.com/xuankuzcr/rpg_vikit.git
正克隆到 'rpg_vikit'...
fatal: 无法访问 'https://github.com/xuankuzcr/rpg_vikit.git/':Failed to connect to github.com port 443: 拒绝连接
lihongli@lhl:~/catkin_ws/src$ git clone https://github.com/xuankuzcr/rpg_vikit.git
正克隆到 'rpg_vikit'...
fatal: 无法访问 'https://github.com/xuankuzcr/rpg_vikit.git/':GnuTLS recv error (-110): The TLS connection was non-properly terminated.
lihongli@lhl:~/catkin_ws/src$ git clone https://github.com/xuankuzcr/rpg_vikit.git
正克隆到 'rpg_vikit'...
^C
lihongli@lhl:~/catkin_ws/src$ git clone https://github.com/xuankuzcr/rpg_vikit.git
正克隆到 'rpg_vikit'...
^C
lihongli@lhl:~/catkin_ws/src$ ping github.com
PING github.com (20.205.243.166) 56(84) bytes of data.
64 字节,来自 20.205.243.166 (20.205.243.166): icmp_seq=1 ttl=112 时间=219 毫秒
64 字节,来自 20.205.243.166 (20.205.243.166): icmp_seq=2 ttl=112 时间=139 毫秒
64 字节,来自 20.205.243.166 (20.205.243.166): icmp_seq=3 ttl=112 时间=108 毫秒
64 字节,来自 20.205.243.166 (20.205.243.166): icmp_seq=4 ttl=112 时间=184 毫秒
^C
--- github.com ping 统计 ---
已发送 4 个包, 已接收 4 个包, 0% 包丢失, 耗时 3004 毫秒
rtt min/avg/max/mdev = 107.550/162.490/218.725/42.443 ms
lihongli@lhl:~/catkin_ws/src$ git config --global http.proxy http://127.0.0.1:7890
lihongli@lhl:~/catkin_ws/src$ git config --global https.proxy http://127.0.0.1:7890
lihongli@lhl:~/catkin_ws/src$ git clone https://github.com/xuankuzcr/rpg_vikit.git
正克隆到 'rpg_vikit'...
remote: Enumerating objects: 394, done.
remote: Counting objects: 100% (95/95), done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 394 (delta 79), reused 74 (delta 74), pack-reused 299 (from 1)
接收对象中: 100% (394/394), 596.75 KiB | 1.28 MiB/s, 完成.
处理 delta 中: 100% (211/211), 完成.
lihongli@lhl:~/catkin_ws/src$