Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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 

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:

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

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

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

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

like image 901
James A. Rosen Avatar asked Sep 24 '08 15:09

James A. Rosen


People also ask

How do I git behind a proxy?

Setting the proxy for Git Run the following commands replacing USERNAME , PASSWORD , PROXY_ADDRESS , and PROXY_PORT with your network's information: git config --global --add http. proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT. git config --global --add https.

Does GIT use Http_proxy?

Now whenever you do anything with [email protected] , it will use the proxy automatically.

Is Git over HTTP?

Git can communicate over HTTP using two different modes.


1 Answers

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

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

like image 166
Derek Mahar Avatar answered Sep 29 '22 14:09

Derek Mahar