How do I pull from a Git repository through an HTTP proxy?

后端 未结 28 2236
星月不相逢
星月不相逢 2020-11-22 11:57

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

相关标签:
28条回答
  • 2020-11-22 12:25

    Setup proxy to git

    command

    git config --global http.proxy http://user:password@domain:port
    

    example

    git config --global http.proxy http://clairton:123456@proxy.clairtonluz.com.br:8080
    
    0 讨论(0)
  • 2020-11-22 12:25

    Set Git credential.helper to wincred.

    git config --global credential.helper wincred
    

    Make sure there is only 1 credential.helper

    git config -l
    

    If there is more than 1 and it's not set to wincred remove it.

    git config --system --unset credential.helper
    

    Now set the proxy with no password.

    git config --global http.proxy http://<YOUR WIN LOGIN NAME>@proxy:80
    

    Check that all the settings that you added looks good....

    git config --global -l
    

    Now you good to go!

    0 讨论(0)
  • 2020-11-22 12:29

    you can use:

    git config --add http.proxy http://user:password@proxy_host:proxy_port
    
    0 讨论(0)
  • 2020-11-22 12:30

    I had the same problem, with a slightly different fix: REBUILDING GIT WITH HTTP SUPPORT

    The git: protocol did not work through my corporate firewall.

    For example, this timed out:

    git clone git://github.com/miksago/node-websocket-server.git
    

    curl github.com works just fine, though, so I know my http_proxy environment variable is correct.

    I tried using http, like below, but got an immediate error.

    git clone http://github.com/miksago/node-websocket-server.git
    
    ->>>  fatal: Unable to find remote helper for 'http' <<<-
    

    I tried recompiling git like so:

    ./configure  --with-curl --with-expat
    

    but still got the fatal error.

    Finally, after several frustrating hours, I read the configure file, and saw this:

    # Define CURLDIR=/foo/bar if your curl header and library files are in

    # /foo/bar/include and /foo/bar/lib directories.

    I remembered then, that I had not complied curl from source, and so went looking for the header files. Sure enough, they were not installed. That was the problem. Make did not complain about the missing header files. So I did not realize that the --with-curl option did nothing (it is, in fact the default in my version of git).

    I did the following to fix it:

    1. Added the headers needed for make:

      yum install curl-devel
      (expat-devel-1.95.8-8.3.el5_5.3.i386  was already installed).
      
    2. Removed git from /usr/local (as I want the new install to live there).

      I simply removed git* from /usr/local/share and /usr/local/libexec

    3. Searched for the include dirs containing the curl and expat header files, and then (because I had read through configure) added these to the environment like so:

      export CURLDIR=/usr/include 
      export EXPATDIR=/usr/include
      
    4. Ran configure with the following options, which, again, were described in the configure file itself, and were also the defaults but what the heck:

      ./configure  --with-curl --with-expat
      
    5. And now http works with git through my corporate firewall:

      git clone http://github.com/miksago/node-websocket-server.git
      Cloning into 'node-websocket-server'...
      * Couldn't find host github.com in the .netrc file, using defaults
      * About to connect() to proxy proxy.entp.attws.com port 8080
      *   Trying 135.214.40.30... * connected
      ...
      
    0 讨论(0)
提交回复
热议问题