Git 通过代理。克隆时出现 407 错误的原因是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8561671/
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
Git through a Proxy. What is causing the 407 error when cloning?
提问by John John Pichler
I'm trying to use Git through a proxy. I've tried setting parameters 'git config --global' in a lot of ways but always without success when cloning repositories.
我正在尝试通过代理使用 Git。我已经尝试以多种方式设置参数“git config --global”,但在克隆存储库时总是没有成功。
I did:
我做了:
git config --global http.proxy http://DOMAIN\\username:[email protected]:8080
git config --global http.sslverify false
git clone http://github.com/project/project.git
And I got:
我得到了:
$ git clone http://github.com/project/project.git folder
Cloning into 'folder'...
error: The requested URL returned error: 407 while accessing http://github.com/project/project.git/info/refs
fatal: HTTP request failed
So, how can I debug this or enable logging in Git to discover why I'm still getting the 407 error? Is there some parameter in Git to verbosely show what is happening to catch the right point where the error is occurring?
那么,我如何调试或启用 Git 登录以发现为什么我仍然收到 407 错误?Git 中是否有一些参数可以详细显示正在发生的事情以捕捉发生错误的正确点?
回答by MonoThreaded
I had a similar problem trying to git push
from a Git Bash client in Windows.
I fixed it just by browsing to the siteusing Chrome.
Then I came back to Git Bash and it worked right away
For clarity, my GIT repository URL looks like http://[email protected]/myproject.git
And I browsed to http://www.cloudforge.com
My understanding is that it forces the proxy to resolve this domain.
我在尝试git push
从 Windows 中的 Git Bash 客户端尝试时遇到了类似的问题。
我只是通过使用 Chrome浏览到网站来修复它。
然后我回到 Git Bash 并立即工作
为清楚起见,我的 GIT 存储库 URL 看起来像http://[email protected]/myproject.git
我浏览到http://www.cloudforge.com
我的理解是它强制代理解析此域。
回答by Dan Cruz
You can enable trace logging to get more information about what Git is doing. Following is an example:
您可以启用跟踪日志记录以获取有关 Git 正在执行的操作的更多信息。下面是一个例子:
GIT_TRACE=$HOME/trace.log git co master
You must use absolute paths if you want to send output to a file. Otherwise, use true or 1 to send output to standard error; e.g. GIT_TRACE=1
.
如果要将输出发送到文件,则必须使用绝对路径。否则,使用 true 或 1 将输出发送到标准错误;例如GIT_TRACE=1
。
回答by ShortM
If you're already behind a proxy and getting this error, you will have to clear http.proxy
andhttps.proxy
:
git config --global --unset http.proxy
git config --global --unset https.proxy
如果您已经在代理后面并收到此错误,则必须清除http.proxy
和https.proxy
:
git config --global --unset http.proxy
git config --global --unset https.proxy
回答by Adam Arold
I think that you should start from the HTTP error: HTTP 407 error explained. And from that you can arrive at the answer: proxy error issue. Hope that helps.
我认为你应该从 HTTP 错误开始:HTTP 407 错误解释。从中您可以得出答案:代理错误问题。希望有帮助。
回答by ederkley
This works for users on a domain and behind proxy with authentication and HTTPS inspection. Use the following where the %5c is used instead of "\". ie. DOMAIN%5cusername@proxy:port
这适用于域中的用户以及具有身份验证和 HTTPS 检查的代理。在使用 %5c 而不是“\”的地方使用以下内容。IE。DOMAIN%5cusername@proxy:port
Open GIT config in editor by entering below command:
通过输入以下命令在编辑器中打开 GIT 配置:
git config --global -e
Add/update following sections and save:
添加/更新以下部分并保存:
[http]
proxy = http://domain%5cusername:password@proxy:port
sslVerify = false
[https]
proxy = http://domain%5cusername:password@proxy:port
sslVerify = false
回答by Hello Universe
The following solved the problem for me
以下为我解决了问题
- Rightclick on the git folder-> TortoiseGit->Settings->Network
- Enable Proxy Server and input proxy, port, user, password
- 右键单击git文件夹-> TortoiseGit->设置->网络
- 启用代理服务器并输入代理、端口、用户、密码
回答by Matthias Lohr
This error may occur if proxy credentials are given, but invalid. In my case, it was an old password.
如果提供了代理凭据,但无效,则可能会发生此错误。就我而言,这是一个旧密码。
回答by thinkOfaNumber
I copied the http proxy section of my .gitconfig to https:
我将 .gitconfig 的 http 代理部分复制到 https:
[http]
proxy = http://user:pass@ip_or_host:port
[https]
proxy = http://user:pass@ip_or_host:port
I put an incorrect password in the http proxy just to check, and it was ignored, so it's the https section that was missing for me.
我在 http 代理中输入了一个错误的密码只是为了检查,但它被忽略了,所以我缺少的是 https 部分。
Strangely, on another day that didn't work. I don't know if I'm going crazy or if there's another step I forgot. In today's case, this method of setting the proxy worked (with a cleared .gitconfig) from the command line:
奇怪的是,在另一天没有工作。我不知道是我疯了还是我忘记了另一个步骤。在今天的情况下,这种设置代理的方法从命令行工作(清除 .gitconfig):
HTTPS_PROXY="http://user:pass@ip_or_host:port/" git clone --progress -v "https://github.com/repo" local_folder
Notes:
笔记:
- If you're on a domain you might need to use the syntax
DOMAIN\user
. - This didn't work for TortoiseGit, but worked in gitbash on Windows.
- 如果您在域中,则可能需要使用语法
DOMAIN\user
. - 这对 TortoiseGit 不起作用,但在 Windows 上的 gitbash 中起作用。
回答by Prabin Tp
Your proxy could also be set as an environment variable. Check if your environment has any of the env variables http_proxy or https_proxy set up and unset them.
您的代理也可以设置为环境变量。检查您的环境是否设置了任何环境变量 http_proxy 或 https_proxy 并取消设置它们。
Using command prompt
使用命令提示符
# Linux
export http://user:pass@ip_or_host:port
export http://user:pass@ip_or_host:port
# Windows
set HTTP_PROXY = http://user:pass@ip_or_host:port
set HTTPS_PROXY = http://user:pass@ip_or_host:port
change Manually
手动更改
- Right click on my computer
- select properties
- advanced system settings advanced->system variables ->add
- 右键单击我的电脑
- 选择属性
- 高级系统设置高级->系统变量->添加
回答by Rijas Madurakuzhi
If you are inside a corporate firewall and you are using windows git bash then:
如果您在公司防火墙内并且您使用的是 windows git bash 那么:
Open global gitconfig file, usually this will be under C:\Users\USER_NAME.gitconfig and add the below lines if not exists.
打开全局 gitconfig 文件,通常这将在 C:\Users\USER_NAME.gitconfig 下,如果不存在则添加以下行。
[http]
proxy = http://USER_NAME:PASSWORD@PROXY_URL:PROXY_PORT
sslverify = false
[https]
proxy = http://USER_NAME:PASSWORD@PROXY_URL:PROXY_PORT
sslverify = false
Make sure your password does not have '@' character. If you still have the problem and you are using proxy url instead IP then: Open command - 'Windows Key+R' and type cmd then hit enter execute the command:
确保您的密码没有“@”字符。如果您仍然有问题,并且您使用的是代理 url 而不是 IP,那么:打开命令 - 'Windows Key+R' 并键入 cmd 然后按回车键执行命令:
nslookup PROXY_URL
nslookup PROXY_URL
This will give some ip addresses. Try these ip addresses in .giconfig instead of PROXY_URL.
这将给出一些IP地址。在 .giconfig 而不是 PROXY_URL 中尝试这些 ip 地址。