Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 views
in Technique[技术] by (71.8m points)

git - 如何通过HTTP代理从Git存储库中提取?(How do I pull from a Git repository through an HTTP proxy?)

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.

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

I have a project under Git control.

(我有一个在Git控制下的项目。)

I'd like to add a submodule:

(我想添加一个子模块:)

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

But I get

(但是我明白了)

...
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'

I have my HTTP_PROXY set up:

(我设置了HTTP_PROXY:)

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

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

(我什至为http代理设置了全局Git设置:)

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

Has anybody gotten HTTP fetches to consistently work through a proxy?

(有没有人获取过HTTP抓取以通过代理一致地工作?)

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).

(真正奇怪的是,GitHub上的一些项目运行良好(例如awesome_nested_set ),但是其他项目却始终失败(例如rails )。)

  ask by James A. Rosen translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can also set the HTTP proxy that Git uses in global configuration property http.proxy :

(您还可以在全局配置属性http.proxy设置Git使用的HTTP代理:)

git config --global http.proxy http://proxy.mycompany:80

To authenticate with the proxy:

(要通过代理进行身份验证:)

git config --global http.proxy http://mydomain\myusername:mypassword@myproxyserver:8080/

(Credit goes to @EugeneKulabuhov and @JaimeReynoso for the authentication format.)

((有关身份验证格式,请转到@EugeneKulabuhov@JaimeReynoso 。))


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...