无法连接到 git 远程存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24543372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:15:51  来源:igfitidea点击:

Unable to connect to git remote repository

gitgithub

提问by LoveProgramming

After performing git push -u origin master, I got:

表演后git push -u origin master,我得到:

fatal: unable to access 'https://github.com/xxxx/xxxx.git': Failed to connect to 127.0.0.1 port 8087: Connection refused

Same error occurred, when I tried to clone other repositories, too.

当我尝试克隆其他存储库时,也发生了同样的错误。

The Port 8087 doesn't seem to be busy. What could go wrong?

端口 8087 似乎并不忙。什么可能出错?

Edit:when I do clone from git://instead of https://, it works just fine.

编辑:当我从而git://不是克隆时https://,它工作得很好。

回答by Laurent

This happens because a proxy is configured in git.

发生这种情况是因为在 git 中配置了代理。

Since it's https proxy (and not http) git config http.proxyand git config --global http.proxycan't help.

因为它是 https 代理(而不是 http)git config http.proxygit config --global http.proxy所以无能为力。

1 : take a look at your git configuration

1:看一下你的git配置

git config --global -l

If you have nothing related to https proxy like https_proxy=...the problem is not here.

如果您没有任何与 https 代理相关https_proxy=...的问题,那么问题就不在这里。

If you have something related to https proxy then remove it from the file ~/.gitconfigand try again

如果您有与 https 代理相关的内容,请将其从文件中删除并重~/.gitconfig

2 : if it still doesn't work, unset environment variables

2 : 如果它仍然不起作用,请取消设置环境变量

Check your environment variables :

检查您的环境变量:

env|grep -i proxy  

You should have one or several lines with https_proxy=...

你应该有一行或几行 https_proxy=...

Unset one by one with : unset https_proxy(or HTTPS_PROXY depending of the name of the variable)

用 : unset https_proxy(或 HTTPS_PROXY 取决于变量的名称)一一取消设置

3 : check environment variables again

3:再次检查环境变量

env|grep -i proxy

env|grep -i proxy

If it shows nothing you should be good.

如果它什么也没显示,你应该很好。

Note : This solution can applies to http and https proxy problems. just the variables name changes from https to http

注意:此解决方案适用于 http 和 https 代理问题。只是变量名称从 https 更改为 http

回答by Sisi Liao

Laurent's answerworked for me. (I am behind corporate firewall.) In my case,

洛朗的回答对我有用。(我在公司防火墙后面。)就我而言,

  • I removed the proxy setting in .gitconfigfile.

  • Everything just work fine. I can clone from a remote repo.

  • When i wanted to push to the remote repo, I generated a ssh key. Then I am able to push.

  • 我删除了.gitconfig文件中的代理设置。

  • 一切正常。我可以从远程仓库克隆。

  • 当我想推送到远程仓库时,我生成了一个ssh key. 然后我就可以推了。

Hope it saves someones 2 hours.

希望它可以节省某人 2 小时。

回答by tdv kiran

I had tried all the methods mentioned above, but I was missing something other than what they have mentioned,

我已经尝试了上面提到的所有方法,但我遗漏了他们提到的以外的东西,

try to update your credentials in Control panel -> User Accounts -> Credential Manager for Gitit worked for me

尝试在“控制面板”->“用户帐户”->“Git 凭据管理器”中更新您的凭据,它对我有用

回答by Mahgol Fa

git config --global --unset http.proxy

git config --global --unset http.proxy

回答by toydarian

It seems that git tries to use a local proxy.

似乎 git 尝试使用本地代理。

Please check your global network-settings and those of git.

请检查您的全局网络设置和 git 的设置。

Use git config http.proxyand git config --global http.proxyto get the proxy-settings of git.

使用git config http.proxygit config --global http.proxy获取 git 的代理设置。