GIT clone over HTTP: who knew?
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
You can also set the http proxy inside git using
git config --global http.proxy proxy_addr:proxy_port
. See git config for details.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
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.
[…] to change my search query to Google, and guess what? I found the answer!! Thanks to link and this […]
Hi,
Thanks for this help!
Works great. Thanks!
Starts to work but in the end console chrashes. Every time!
did you remember to set up any proxy settings that you might need? also what is the error that you’re getting. just saying that it doesn’t work and crashes doesn’t help me to determine the problem
Thank you.
Among the solutions I found on the web, yours is the simplest.
If you’re behind an authenticated proxy — and don’t want to store your password as cleartext — you can use this script:
#!/usr/bin/bash
read -p “Proxy password: ” -s passwd
echo
env “http_proxy=http://$HTTP_PROXY_USER:$passwd@$HTTP_PROXY:80” git “$@”
Note that under Windows (msysgit), the environment variable must be upper-case: HTTP_PROXY
Awesome, that worked. (git config for proxy + http://github.com/blah)
Thanks 🙂 works nicely
thx very much! you saved me!
Thank you man, ur a genious!!
Thanks a lot ! it is sooo simple and i’ve been searching for sooo long ….