Git 克隆错误“连接后来自代理的 HTTP 代码 504”

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

Git clone error "HTTP code 504 from proxy after CONNECT"

gitproxyfirewallbitbucket-server

提问by manuelbcd

I'm working in a office behind a corporate firewall. My System is windows7, using componentes consola. Usually I need to set up proxy connections to get GIT working with github.

我在公司防火墙后面的办公室工作。我的系统是 windows7,使用组件 consola。通常我需要设置代理连接才能让 GIT 与 github 一起工作。

But when I try to clone a repository sored in a private Stash (Atlassian) I get this error:

但是当我尝试克隆一个存储在私有 Stash (Atlassian) 中的存储库时,我收到此错误:

Cloning into 'apptest'...
fatal: unable to access 'https://[email protected]:xxxx/apptest/apptest.git
/': Received HTTP code 504 from proxy after CONNECT

I have unsetted git proxy but I'm still facing same problem. Please note that I'm using GITshell over Windows 7

我没有设置 git 代理,但我仍然面临同样的问题。请注意,我在 Windows 7 上使用 GITshell

Any help would be appreciated.

任何帮助,将不胜感激。

Regards

问候

回答by manuelbcd

Problem solved.

问题解决了。

Windows: Before connecting Bitbucket(AKA stash) you need to clean all proxies from both Git and console environment:

Windows:在连接Bitbucket(AKA stash) 之前,您需要清除 Git 和控制台环境中的所有代理:

SET HTTP_PROXY=
SET HTTPS_PROXY=
git config --global --unset http.proxy
git config --global --unset https.proxy
git clone http://yourUser@stashAddress:stashPort/apptest.git

But if you need to connect to public repositories like github, then it's necessary to define proxies again:

但是如果你需要连接到像github这样的公共存储库,那么就需要再次定义代理:

SET HTTP_PROXY=proxyaddress:port
SET HTTPS_PROXY=proxyaddress:port
git config --global http.proxy http://proxyaddress:port
git config --global https.proxy http://proxyaddress:port

I think it may be useful for other developers working behind corporate firewalls.

我认为它可能对在公司防火墙后面工作的其他开发人员有用。

Linux

Linux

unset HTTP_PROXY
unset HTTPS_PROXY
git config --global --unset http.proxy
git config --global --unset https.proxy
git clone http://yourUser@stashAddress:stashPort/apptest.git

To define proxies again:

再次定义代理:

export HTTP_PROXY=proxyaddress:port
export HTTPS_PROXY=proxyaddress:port
git config --global http.proxy http://proxyaddress:port
git config --global https.proxy http://proxyaddress:port

Take care with uppercase of environment variables. Some OS versions may need lowercase or may have defined lowercase variables by default.

注意环境变量的大写。某些操作系统版本可能需要小写或可能默认定义了小写变量。

回答by Raj Shah

If you definitely need the proxy and can't remove it (eg: if you're on a corporate proxy) then just use the ssh to clone the repo.

如果您确实需要代理并且无法删除它(例如:如果您使用的是公司代理),那么只需使用 ssh 来克隆存储库。

回答by davide79

Problem Solved in SourceTree

SourceTree 中解决的问题

Hoping this might be of any help to other developers who use (like I do) SourceTreeon Windows. Many thanks to @manuelbcd for his initial answer.

希望这可能对在 Windows 上使用(像我一样)SourceTree 的其他开发人员有任何帮助。非常感谢@manuelbcd 的初步回答。

I was experience a similar problem (HTTP status code was 502 with the same error message) when I was trying to fetch, pullor pushfrom the BitBucket, and no extra configuration was done in my local git configuration, and I could not understand why I was getting this error.

当我尝试从 BitBucket获取推送时遇到了类似的问题(HTTP 状态代码为 502,错误消息相同),并且在本地 git 配置中没有进行额外的配置,我不明白为什么我收到这个错误。

SOLUTIONIn the list of the Environment Variable(Windows 7) HTTP_PROXY and HTTPS_PROXY were set. Since I did not need them I removed from there and relaunchedSourceTree.

解决方案环境变量(Windows 7) 列表中设置了 HTTP_PROXY 和 HTTPS_PROXY。由于我不需要它们,我从那里删除并重新启动SourceTree

In order to find the Environment Variable(Windows 7) click on Startand type enviro. At the top of the menu comes out the line Edit environment variable..., click on it, remove/rename the variable and save.

为了找到环境变量(Windows 7),点击开始并输入enviro。菜单顶部出现一行Edit environment variable...,单击它,删除/重命名变量并保存

Relaunch SourceTree at the end.

最后重新启动 SourceTree。