如何通过 HTTP 代理从 Git 存储库中提取? [英] How do I pull from a Git repository through an HTTP proxy?

查看:20
本文介绍了如何通过 HTTP 代理从 Git 存储库中提取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:虽然所描述的用例是关于在项目中使用子模块,但这同样适用于通过 HTTP 存储库的普通 git clone.

Note: while the use-case described is about using submodules within a project, the same applies to a normal git clone of a repository over HTTP.

我有一个在 Git 控制下的项目.我想添加一个子模块:

I have a project under Git control. I'd like to add a submodule:

git submodule add http://github.com/jscruggs/metric_fu.git vendor/plugins/metric_fu

但是我明白了

...
got 1b0313f016d98e556396c91d08127c59722762d0
got 4c42d44a9221209293e5f3eb7e662a1571b09421
got b0d6414e3ca5c2fb4b95b7712c7edbf7d2becac7
error: Unable to find abc07fcf79aebed56497e3894c6c3c06046f913a under http://github.com/jscruggs/metri...
Cannot obtain needed commit abc07fcf79aebed56497e3894c6c3c06046f913a
while processing commit ee576543b3a0820cc966cc10cc41e6ffb3415658.
fatal: Fetch failed.
Clone of 'http://github.com/jscruggs/metric_fu.git' into submodule path 'vendor/plugins/metric_fu'

我设置了 HTTP_PROXY:

I have my HTTP_PROXY set up:

c:project> echo %HTTP_PROXY%
http://proxy.mycompany:80

我什至有一个用于 http 代理的全局 Git 设置:

I even have a global Git setting for the http proxy:

c:project> git config --get http.proxy
http://proxy.mycompany:80

有没有人通过代理获得 HTTP 获取以始终如一地工作?真正奇怪的是,GitHub 上的一些项目运行良好(awesome_nested_set for例如),但其他人总是失败(例如rails).

Has anybody gotten HTTP fetches to consistently work through a proxy? What's really strange is that a few project on GitHub work fine (awesome_nested_set for example), but others consistently fail (rails for example).

推荐答案

最终起作用的是设置 http_proxy 环境变量.我已经正确设置了 HTTP_PROXY,但 git 显然更喜欢小写版本.

What finally worked was setting the http_proxy environment variable. I had set HTTP_PROXY correctly, but git apparently likes the lower-case version better.

这篇关于如何通过 HTTP 代理从 Git 存储库中提取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆