项目场景:

Windows 10 + visual studio 2019

问题描述:

在push 和 clone项目的时候会出现错误:

发布到远程存储库时遇到错误: Git failed with a fatal error.
unable to access 'https://github.com/xxx.git/': Failed to connect to github.com port 443: Timed out
Pushing to https://github.com/ZZUboys/MG039101837_visual_detect.git

原因分析:

GitHub可以登上,使用 ping 命令测试 「github.com]结果果与错误一样也是连接超时。Google了一下,网上说是代理的问题


解决方案:


进入「网络和 Internet」设置的代理设置界面,看见「使用设置脚本」是打开的,并且有一个脚本地址,在浏览器中访问脚本地址会自动下载名为「pac」的文件,文件内容是需要进行代理的域名配置和使用代理的逻辑,搜索一下可以找到「github.com」也位列其中。
Failed to connect to github.com port 443: Timed out_网络



在 「pac」文件中找到 「proxy」的值,将其设置为 git 的 http.proxy 的值



git config --global http.proxy 127.0.0.1:1080 为全局的 git 项目都设置代理
git config --local http.proxy 127.0.0.1:1080 为某个 git 项目单独设置代理

http.proxy 值为下图中标记部分:

Failed to connect to github.com port 443: Timed out_网络_02

参考:https://www.jianshu.com/p/7d728d5976df