Git:HTTP 请求失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8644947/
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 12:36:13  来源:igfitidea点击:

Git : HTTP request failed

githttp

提问by Oodini

I have a remote repository with HTTPS access.

我有一个具有 HTTPS 访问权限的远程存储库。

git statuslists only one entry: master

git status只列出一个条目:master

git remote -vlists two entries to the same address: one for fetch, one for push

git remote -v列出同一地址的两个条目:一个用于获取,一个用于推送

But when I do git remote show origin, or other operations, like fetch, I get :

但是,当我执行git remote show origin或其他操作时,例如fetch,我得到:

error: while accessing https:...
fatal: HTTP request failed

I am behind a proxy, but as it is set in my .gitconfig (sslVerify = no) and the cloning is OK, I don't think the problem comes from that.

我在代理后面,但因为它是在我的 .gitconfig (sslVerify = no) 中设置的,并且克隆是可以的,我认为问题不是来自于此。

BUT... my OS (CentOS) has been reinstalled.

但是...我的操作系统 (CentOS) 已重新安装。

回答by Alasdair Allan

If you're using https:rather than git:for your clone, it's possible that it's barfing on the CA certificate, i.e. you don't have a copy of the intermediate certificate to verify your SSL connection. I've run into this on a couple of different occasions. Usually with debian-based Linux distributions. Try

如果您正在使用https:而不是git:用于您的克隆,则它可能会对 CA 证书产生影响,即您没有中间证书的副本来验证您的 SSL 连接。我在几个不同的场合遇到过这种情况。通常使用基于 debian 的 Linux 发行版。尝试

git config --global http.sslVerify false

and then the clone again. If the clone works, that's what's happening. However this is a bad solution, as of course turns off SSL verification, which makes using HTTPS somewhat pointless, and leaves you vulnerable to man-in-the-middle attacks.

然后再次克隆。如果克隆有效,那就是正在发生的事情。然而,这是一个糟糕的解决方案,因为当然会关闭 SSL 验证,这使得使用 HTTPS 变得有些毫无意义,并使您容易受到中间人攻击。

What you need to do is download the CA Certificates package for whatever OS you're on, under Linux (well Debian/Ubuntu) it'll probably be something like

您需要做的是为您使用的任何操作系统下载 CA 证书包,在 Linux(以及 Debian/Ubuntu)下,它可能类似于

apt-get install ca-certificates

then

然后

git config --global http.sslVerify true
git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt

although your path to your certificate file might be different depending on OS version.

尽管您的证书文件路径可能因操作系统版本而异。

This should get it working.

这应该让它工作。

回答by Joachim Werner

I had set the http proxy in the HTTP_PROXY environment variable (Git Bash on Windows), but only setting the proxy in my %HOME%/.gitconfig worked:

我已经在 HTTP_PROXY 环境变量(Windows 上的 Git Bash)中设置了 http 代理,但只在我的 %HOME%/.gitconfig 中设置了代理:

[http]
    proxy = http://USERNAME:PASWORD@URL:PORT

回答by mdziob

I've got the same error, but quite other problem than mentioned in the rest answers. I was trying to clone repository on linux:

我遇到了同样的错误,但与其他答案中提到的问题完全不同。我试图在 linux 上克隆存储库:

git clone http://xxx/scm/xxx/xxx.git
Initialized empty Git repository in /opt/git/xxx/.git/
Password:
error: Failed connect to xxx:80; Operation now in progress while accessing http://xxx.git/info/refs

fatal: HTTP request failed

It was all because wrong permissions to folder - but git instead of some permissions error throws HTTP request failed. So if someone will encounter similar problem - check folder permissions!

这完全是因为文件夹权限错误 - 但是 git 而不是某些权限错误会引发 HTTP 请求失败。所以如果有人会遇到类似的问题 - 检查文件夹权限!