Git proxy bypass

前端 未结 7 1995
借酒劲吻你
借酒劲吻你 2020-12-07 14:07

Git works in a proxied environment by setting the http.proxy configuration parameter.

For certain addresses I need to bypass the proxy. Is there a no-proxy/bypass-p

相关标签:
7条回答
  • 2020-12-07 14:19

    Make sure you have a Git 2.1.2+ if you want to set a config to an empty value, like

    git config --add remote.origin.proxy ""
    

    Because if you decide to restore a proxy for that remote (here 'origin')... it will segfault with a Git older than 2.1.2 (Sept. 30th, 2014)

    See commit c846664 (tanayabh)

    make config --add behave correctly for empty and NULL values

    Currently if we have a config file like,

    [foo]
            baz
            bar =
    

    and we try something like, "git config --add foo.baz roll", Git will segfault. Moreover, for "git config --add foo.bar roll", it will overwrite the original value instead of appending after the existing empty value.

    The problem lies with the regexp used for simulating --add in git_config_set_multivar_in_file(), "^$", which in ideal case should not match with any string but is true for empty strings.
    Instead use a regexp like "a^" which can not be true for any string, empty or not.

    For removing the segfault add a check for NULL values in matches() in config.c.

    0 讨论(0)
  • 2020-12-07 14:20

    Assuming you are starting by cloning, the origin-config things are not so useful. When I find myself in that position I do.

    $> no_proxy=$no_proxy,<git-url|ip> git clone ...
    

    Note that this will be per command. To make this permanent for the repo just cloned, you can now go to the newly cloned repo and add the empty-proxy setting.

    $> git config --add remote.origin.proxy ""
    

    However, if you want this host or IP excluded from proxy in all cases, use your shells init-file to do the inclusion of your origins permanent for your user.

    I would put the following line last in .bashrc

    export no_proxy=$no_proxy,<your repo>
    

    I hope that makes things clearer!

    0 讨论(0)
  • 2020-12-07 14:22

    The proxy can be overridden on a per-remote basis - see http://git-scm.com/docs/git-config (look for the "http.proxy" and "remote.<name>.proxy" settings). Assuming you have the remote called "origin" then the command you could use to bypass proxy for this remote is:

    git config --add remote.origin.proxy ""
    
    0 讨论(0)
  • 2020-12-07 14:23

    Due to Windows / Unix user role, if you can't eliminate the http_proxy from command line, please try this approach -

    git config -l --show-origin
    

    That will print the configurations based present on the files according to hierarchy. Now go to specific file (local .git/config folder file) and update / remove the http_proxy.

    Hope this helps.

    0 讨论(0)
  • 2020-12-07 14:25

    just execute below command on command prompt

    git config --global http.proxy [Proxy IP]:[Proxy port]
    
    0 讨论(0)
  • 2020-12-07 14:39

    Accepted answer requires the git repo to exist before hand to work and the second best answer works only for linux & Mac. So in windows to make it work for https://git-url.com/project/repo-name.git try the following in a command prompt

    set no_proxy=git-url.com
    

    then

    git clone git-url.com/repo-name.git
    

    Now you will have a repo to apply the accepted answer.

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