致命:无法连接到 github.com: github.com[0: 140.82.121.4]: errno=未知错误

Ahl*_*ini 18 git git-push git-remote

我的 Git 帐户有问题。每次执行时git push,我都会收到以下错误:

Git推送错误

我发现我正在使用 SSH URL:

SSH 网址

我尝试使用以下命令切换回 HTTPS URL:

git config --global url.https://github.com/.insteadOf git://github.com/
git config --global url."https://".insteadOf git://
Run Code Online (Sandbox Code Playgroud)

然而,它似乎并没有改变任何事情: 例子

我尝试了许多我认为是解决方案的选项,例如手动配置配置文件,但没有任何效果。

小智 70

发生此错误是因为您的git 端口受到限制
因此,您可以使用以下命令修复它:

git config --global url.https://github.com/.insteadOf git://github.com/
Run Code Online (Sandbox Code Playgroud)

通过在全球范围内执行此操作,它还可以修复可能正在使用旧存储库或其他场景的其他问题,git而不是https端口git:///协议现在与以前相比无法运行的问题。

如果对您有用请点赞!
谢谢。


Mim*_*ime 4

要使用gitwith ssh,需要不同的 url 语法,即git@<url>as url。根据您的屏幕截图,网址很可能如下所示

git@github.com:ahlemtbini/blog_web.git
Run Code Online (Sandbox Code Playgroud)

您可以使用以下命令更改它

git remote set-url origin git@github.com:ahlemtbini/blog_web.git
Run Code Online (Sandbox Code Playgroud)

如果您正在使用,我建议您始终使用该存储库页面的- 按钮github下列出的 url 。更多信息请点击此处codegithub

有关 git 使用的协议的更多信息,请阅读有关git 服务器协议的页面。