Git proxy bypass

2019-01-16 10:22发布

问题:

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-proxy configuration parameter?

回答1:

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 ""


回答2:

To bypass proxy for certain, usually a local address, all you need to do is:

export no_proxy=URLToIgnore

Where URLToIgnore is the URL that you want Git to ignore. You can also ignore URLs ending with a certain word.

export no_proxy=.mylocal

Where all urls ending with .mylocal will get ignored. To ignore multiple URLs:

export no_proxy=.mylocal URLToIgnore

To make it permanent, add it to your ~/username/.bash_profile file. If you cannot find .bash_profile file in your user root directory, then manually create it.

For more details: How to temporarily disable git http proxy



回答3:

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.



回答4:

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.



回答5:

export http_proxy=http://username:password@ip:port
export no_proxy=myhost, myhost:port


回答6:

just execute below command on command prompt

git config --global http.proxy [Proxy IP]:[Proxy port]


标签: git http proxy