Rip's Domain

GIT clone over HTTP: who knew?

Posted in Git, TechSupport by rip747 on 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

Tagged with:

16 Responses

Subscribe to comments with RSS.

  1. happygiraffe said, on 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.

  2. dilipm said, on 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

  3. Emil Sit said, on 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.

  4. […] to change my search query to Google, and guess what? I found the answer!! Thanks to link and this […]

  5. Venkat said, on July 8, 2009 at 11:32 am

    Hi,

    Thanks for this help!

  6. Vernod said, on January 4, 2010 at 11:49 am

    Works great. Thanks!

  7. Mikhail said, on February 25, 2010 at 10:36 am

    Starts to work but in the end console chrashes. Every time!

  8. rip747 said, on February 25, 2010 at 3:48 pm

    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

  9. Thiago said, on March 11, 2010 at 8:15 pm

    Thank you.

    Among the solutions I found on the web, yours is the simplest.

  10. Thiago said, on March 21, 2010 at 12:09 am

    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 “$@”

  11. Dejan said, on May 31, 2010 at 1:32 pm

    Note that under Windows (msysgit), the environment variable must be upper-case: HTTP_PROXY

  12. Almo said, on October 25, 2010 at 2:12 pm

    Awesome, that worked. (git config for proxy + http://github.com/blah)

  13. ersran9 said, on February 3, 2011 at 12:17 pm

    Thanks 🙂 works nicely

  14. Christian said, on August 1, 2011 at 9:57 am

    thx very much! you saved me!

  15. Sethathi said, on February 4, 2012 at 3:51 pm

    Thank you man, ur a genious!!

  16. Roman said, on June 12, 2012 at 8:18 am

    Thanks a lot ! it is sooo simple and i’ve been searching for sooo long ….


Leave a comment