解决 GitHub 连接失败

问题描述

在连接使用 git clone 等命令连接 GitHub 时报错:

1
fatal: unable to access 'https://github.com/xxx/xxx.git/': Failed to connect to github.com port 443 after 21160 ms: Couldn't connect to server

挂了梯子GitHub网页可以正常打开,但在命令行访问远程仓库时失败。

解决方法

1
2
git config --global https.proxy http://127.0.0.1:xxxxx
git config --global http.proxy http://127.0.0.1:xxxxx

该命令用于配置 Git 使用代理服务器,以便通过代理访问 Git 仓库,“xxxxx”表示所用梯子的代理端口号(根据clash、V2rayN等有所不同,我使用的时sukuracat,端口号为33210)。