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

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

    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!

提交回复
热议问题