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

后端 未结 28 2235
星月不相逢
星月不相逢 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:15

    Just to post this as it is the first result on Google, this blog post I found solves the problem for me by updated the curl certificates.

    http://www.simplicidade.org/notes/archives/2011/06/github_ssl_ca_errors.html

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

    On Windows, if you don't want to put your password in .gitconfig in the plain text, you can use

    • Cntml (http://cntlm.sourceforge.net/)

    It authenticates you against normal or even Windows NTLM proxy and starts localhost-proxy without authentication.

    In order to get it run:

    • Install Cntml
    • Configure Cntml according to documentation to pass your proxy authentication
    • Point git to your new localhost proxy:

      [http]
          proxy = http://localhost:3128       # change port as necessary
      
    0 讨论(0)
  • 2020-11-22 12:17

    It looks like you're using a mingw compile of Git on windows (or possibly another one I haven't heard about). There are ways to debug this: I believe all of the http proxy work for git is done by curl. Set this environment variable before running git:

    GIT_CURL_VERBOSE=1
    

    This should at least give you an idea of what is going on behind the scenes.

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

    What finally worked was setting the http_proxy environment variable. I had set HTTP_PROXY correctly, but git apparently likes the lower-case version better.

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

    Worth to mention: Most examples on the net show examples like

    git config --global http.proxy proxy_user:proxy_passwd@proxy_ip:proxy_port
    

    So it seems, that - if your proxy needs authentication - you must leave your company-password in the git-config. Which isn't really cool.

    But, if you just configure the user without password:

    git config --global http.proxy proxy_user@proxy_ip:proxy_port
    

    Git seems (at least on my Windows-machine without credentials-helper) to recognize that and prompts for the proxy-password on repo-access.

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

    There's some great answers on this already. However, I thought I would chip in as some proxy servers require you to authenticate with a user Id and password. Sometimes this can be on a domain.

    So, for example if your proxy server configuration is as follows:

    Server: myproxyserver
    Port: 8080
    Username: mydomain\myusername
    Password: mypassword
    

    Then, add to your .gitconfig file using the following command:

    git config --global http.proxy http://mydomain\\myusername:mypassword@myproxyserver:8080
    

    Don't worry about https. As long as the specified proxy server supports http, and https, then one entry in the config file will suffice.

    You can then verify that the command added the entry to your .gitconfig file successfully by doing cat .gitconfig:

    At the end of the file you will see an entry as follows:

    [http]
        proxy = http://mydomain\\myusername:mypassword@myproxyserver:8080
    

    That's it!

    0 讨论(0)
提交回复
热议问题