Git 克隆错误 "HTTP code 504 from proxy after CONNECT"

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

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

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

Cloning into 'apptest'...
fatal: unable to access 'https://xxx@xxx.xx.xx.xx:xxxx/apptest/apptest.git
/': Received HTTP code 504 from proxy after CONNECT

我已经取消设置 git 代理,但我仍然面临同样的问题。 请注意,我使用 GITshell 而不是 Windows 7

如有任何帮助,我们将不胜感激。

此致

问题已解决。

Windows:在连接 Bitbucket(又称 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

但是如果你需要连接到 public 存储库,如 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

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

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

再次定义代理:

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

注意环境变量的大写。某些 OS 版本可能需要小写字母或默认定义了小写字母变量。

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

SourceTree 中已解决的问题

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

我在尝试 fetchpull[=38= 时遇到了类似的问题(HTTP 状态代码为 502,并出现相同的错误消息) ] 或 push 来自 BitBucket,并且在我的本地 git 配置中没有进行额外的配置,我不明白为什么会出现此错误。

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

为了找到环境变量 (Windows 7) 点击开始并输入enviro .在菜单顶部出现 Edit environment variable... 行,单击它,remove/rename 变量和 保存

最后重新启动 SourceTree。