Question

Now I need to clone some repositorys,but They are banned,then I read some words from https://www.kernel.org/pub/software/scm/git/docs/git-config.html:

http.proxy

Override the HTTP proxy, normally configured using the http_proxy, https_proxy, and all_proxy environment variables (see curl(1)). This can be overridden on a per-remote basis; see remote..proxy

Then I set the three env virables:

export all_proxy="domain.com:8888"
export http_proxy="domain.com:8888"
export https_proxy="domain.com:8888"

But It didn't work,then I reset them to "",then i set http.proxy use this:

git config --local http.proxy "domain.com"

It works.But I shouldn't set global,because there may be others are cloning but they shouldn't use proxy,and why It didn't work by set that three env virables?

Était-ce utile?

La solution

Either because you set the env to domain.com:8888 and did not specify a port in the git config, or because you need to uppercase those env vars.

Also you do realize, that you can set git vars per repo? So you could do:

git init myrepo
cd myrepo
git config http.proxy "domain.com"
git remote add origin myremote
git fetch --all
git checkout -B master origin/master

And then only this repo would you the proxy.

Autres conseils

You can (at least now) also pass the proxy setting together with the clone command:

git clone https://github.com/user/repository.git --config "http.proxy=host:port"
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top