如下图,在服务器上git clone项目时,总是一直显示“Cloning into ...”,过了好久才显示”fatal: unable to access ... :Failed to connect to github.com port 443: Connection timed out“.

最开始,以为是网络问题,但是后来发现网络连接没问题。
然后又查帖,有说是代理的问题:
尝试了 网上的 设置代理:
git config --global https.proxy [http://127.0.0.1:1080](http://127.0.0.1:1080/)
git config --global https.proxy [https://127.0.0.1:1080](https://127.0.0.1:1080/)
和取消代理:
git config --global --unset http.proxy
git config --global --unset https.proxy
尝试后都没有解决问题,才发现报的都不是一个错,不是这个port 443的问题。
最后参考 https://blog.youkuaiyun.com/hustsselbj/article/details/46842191?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase 和 https://blog.youkuaiyun.com/qq_45435600/article/details/98177142 终于解决了。
就是 修改 /etc/hosts 文件
vim /etc/hosts
把跟github.com 相关的行注释掉,重新git clone,就成功啦!
本文详细记录了解决在服务器上使用GitClone项目时遇到的长时间等待和连接超时问题的过程,通过修改/etc/hosts文件中与github.com相关的条目,最终成功解决了问题。
1万+

被折叠的 条评论
为什么被折叠?



