GIT clone over HTTP: who knew?
September 12, 2008
Quick note for others and so I don’t forget.
If you’re behind a proxy (like I am) and try to do a git-clone using the git:// protocol, surely it will fail if you’re firewall is restrictive. The beautiful thing is, you can use http:// protocol instead to get around this restriction.
So for instance, let’s say we want to clone a copy of yubnub from github. In the cygwin command line, you would normally do:
git clone git://github.com/jcnetdev/yubnub.git
However that will fail. Instead do:
git clone http://github.com/jcnetdev/yubnub.git
The only other gotcha is that you might need to setup your proxy in your environment. To do this, simply do:
export http_proxy=http://<username>:<password>@<proxy_ip>:<proxy_port>
where:
username = your network username (someuser)
password = your network password (somepassword)
proxy_ip = the ip address of your proxy server (192.168.1.1)
proxy_port = the port number for the proxy (80)
the full string would look like this:
export http_proxy=http://someuser:somepassword@192.168.1.1:80
September 16, 2008 at 5:49 am
You can also set the http proxy inside git using
git config --global http.proxy proxy_addr:proxy_port. See git config for details.November 3, 2008 at 8:11 am
setting this in git config make sense
But I am behind proxy and when trying to clone, I am getting..
fatal: http://www.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/info/refs download error – The requested file was not found
Any help would be greatly appreciated.
–
Dilip
December 9, 2008 at 1:31 pm
This will only work (I think) if the remote site has been configured to serve its git repository over HTTP. If it has not, you will need to configure your proxy to allow CONNECT requests to port 9418 and then use a tool like socat to explicitly proxy the git protocol through. I just put up some instructions on my blog to demonstrate how to do that.
June 4, 2009 at 9:23 am
[...] to change my search query to Google, and guess what? I found the answer!! Thanks to link and this [...]
July 8, 2009 at 11:32 am
Hi,
Thanks for this help!