当推送到远程仓库时出现"无法连接到github.com的443端口:连接超时"错误。

7

我已经在谷歌和stackoverflow上搜索了很多,但是我没有找到解决我的问题的方法。

我使用Ubuntu并且是第一次尝试git。

我做了以下操作:

sudo apt-get install git

我在网站上创建了一个帐户(并验证了电子邮件,一切都很好)。然后我

git config --global user.name "<my_name_here>"

并且

git config --global user.email "<my_email_here>"

我前往该网站并创建了一个名为gittest的公共代码库(我没有使用README初始化,也没有添加许可证或.gitignore文件)。然后我

mkdir gittest

在我的桌面上和
cd /Desktop/gittest

然后:

echo "# gittest" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/<my_username>/gittest.git

最后

git push -u origin master

这就是悲剧:在输入git push -u origin master后按下回车键,却不起作用。数秒后,它返回一个错误消息:

致命错误:无法访问 'https://github.com//gittest.git/':连接到 github.com 的 443 端口超时

  • 我该如何解决?请帮忙

编辑

如果我

echo "$http_proxy"

或者

echo "$https_proxy"

什么都没有发生(终端会返回一个空行)。


可能的规范问题(37个答案):*GitHub - 连接到github 443 windows失败/连接到gitHub失败-没有错误* - Peter Mortensen
或许这个问题更适合你(27个回答和1,019个赞):如何让Git在代理服务器下工作 - 出现“请求超时”的错误 - Peter Mortensen
3个回答

1

尝试运行以下命令

git config --global --unset https.proxy


1
如果您在代理后面,您需要进行配置:
http.proxy

覆盖HTTP代理,通常使用http_proxyhttps_proxyall_proxy环境变量进行配置(参见curl(1))。

除了curl所理解的语法外,还可以使用带有用户名但没有密码的代理字符串,此时Git将尝试以与其他凭据相同的方式获取密码。有关更多信息,请参见gitcredentials(7)。因此,语法为[protocol://][user[:password]@]proxyhost[:port]。这可以在每个远程基础上进行覆盖;请参阅remote.<name>.proxy。

完美!

为了解决“无法连接到github.com端口443:超时”消息,我们需要运行:

git config --global http.proxy

http://domain.local\username:password@proxyServer:8080

其中username是您在代理中的用户名,password是您的密码。

完成!您可以通过运行git config --global http.proxy来检查设置是否已应用。

附加信息:

git config

我需要在\vsilva:Passw0rd处替换什么?我需要用我的本地IPv4地址替换domain.local吗? - HeyBoo

0

解决方案是覆盖SSH设置。

$ vim ~/.ssh/config

# You can also manually open the file and copy/paste the section below
# Add section below to it
Host github.com
  Hostname ssh.github.com
  Port 443

然后尝试

$ ssh -T git@github.com
Hi ! You've successfully authenticated, but GitHub does not
provide shell access.

现在试试

git push -u origin master

这应该是成功的!!!

欲了解更多信息,请查看参考资料:点击此处


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接