推送到远程存储库时出现“无法连接到 github.com 端口 443:连接超时”

Hey*_*Boo 7 linux git ubuntu github

我已经“谷歌搜索”和“stackoverflowed”了很多次,但还没有找到解决我的问题的方法。

我在 Ubuntu 上,第一次尝试git。

我做了:

sudo apt-get install git
Run Code Online (Sandbox Code Playgroud)

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

git config --global user.name "<my_name_here>"
Run Code Online (Sandbox Code Playgroud)

git config --global user.email "<my_email_here>"
Run Code Online (Sandbox Code Playgroud)

然后我访问该网站并创建了一个名为的公共存储库gittest(我没有使用自述文件进行初始化,也没有添加许可证或 .gitignore)。然后我

mkdir gittest
Run Code Online (Sandbox Code Playgroud)

在我的桌面上和

cd /Desktop/gittest
Run Code Online (Sandbox Code Playgroud)

然后:

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
Run Code Online (Sandbox Code Playgroud)

最后

git push -u origin master
Run Code Online (Sandbox Code Playgroud)

这就是悲剧:通过在写入后单击 Enter,git push -u origin master它什么也不做,并且在(许多)秒后返回一条错误消息:

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

  • 我该如何解决?请帮忙

编辑

如果我

echo "$http_proxy"
Run Code Online (Sandbox Code Playgroud)

或者

echo "$https_proxy"
Run Code Online (Sandbox Code Playgroud)

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

小智 1

如果您使用代理,则需要配置:

\n
http.proxy\n
Run Code Online (Sandbox Code Playgroud)\n

覆盖 HTTP 代理,通常使用http_proxyhttps_proxyall_proxy配置(请参阅curl(1))。

\n

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

\n

完美的!

\n

为了解决 \xe2\x80\x9cFailed to connect to github.com port 443: Timed out\xe2\x80\x9d 消息,我们需要运行:

\n

git config --global http.proxy

\n

http://domain.local\\用户名:密码@proxyServer:8080

\n

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

\n

完毕!您可以运行 git config --global http.proxy 检查是否应用了该设置

\n

附加信息:

\n
git config\n
Run Code Online (Sandbox Code Playgroud)\n