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

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

    If you just want to use proxy on a specified repository, don't need on other repositories. The preferable way is the -c, --config <key=value> option when you git clone a repository. e.g.

    $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git --config "http.proxy=proxyHost:proxyPort"
    
    0 讨论(0)
  • 2020-11-22 12:07

    You could too edit .gitconfig file located in %userprofile% directory on Windows system (notepad %userprofile%.gitconfig) or in ~ directory on Linux system (vi ~/.gitconfig) and add a http section as below.

    Content of .gitconfig file :

    [http]
            proxy = http://proxy.mycompany:80
    
    0 讨论(0)
  • 2020-11-22 12:07

    As this was answered by many but This is just for Winodws USER who is behind proxy with auth.

    Re-Installing(first failed, Don't remove).

    Goto ->
    **Windows**
    1. msysgit\installer-tmp\etc\gitconfig
        Under [http]
            proxy = http://user:pass@url:port
    
    **Linux**
    1. msysgit\installer-tmp\setup-msysgit.sh
          export HTTP_PROXY="http://USER:PASS@proxy.abc.com:8080"
    

    if you have any special char in user/pass use url_encode

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

    You can also set the HTTP proxy that Git uses in global configuration property http.proxy:

    git config --global http.proxy http://proxy.mycompany:80
    

    To authenticate with the proxy:

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

    (Credit goes to @EugeneKulabuhov and @JaimeReynoso for the authentication format.)

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

    For me the git:// just doesn't work through the proxy although the https:// does. This caused some bit of headache because I was running scripts that all used git:// so I couldn't just easily change them all. However I found this GEM

    git config --global url."https://github.com/".insteadOf git://github.com/
    
    0 讨论(0)
  • 2020-11-22 12:10

    The above answers worked for me when my proxy doesn't need authentication. If you are using proxy which requires you to authenticate then you may try CCProxy. I have small tutorial on how to set it up here,

    http://blog.praveenkumar.co.in/2012/09/proxy-free-windows-xp78-and-mobiles.html

    I was able to push, pull, create new repos. Everything worked just fine. Make sure you do a clean uninstall and reinstall of new version if you are facing issues with Git like I did.

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