git临时设置的http.proxy

Jef*_*der 7 git

我几乎总是在防火墙后面工作,并使用在全局git配置中设置的http代理。我时不时地被困在防火墙外的公共场所,并恢复为非代理生活方式。这意味着告诉我的浏览器不要使用代理等,一旦我安全返回并在一个友好的位置就必须撤消该代理等。

我想在防火墙外部进行一次拉动或使用git进行提交/推送,但是我不想从配置中删除代理设置,因为从现在开始的一个小时后,我将不得不再次将其添加回去。我想这样

git -c http.proxy="" pull
Run Code Online (Sandbox Code Playgroud)

要么

git --unset http.proxy pull
Run Code Online (Sandbox Code Playgroud)

这样我就可以在没有代理的情况下进行一次拉动。但是第一个结果error: Missing value for 'http.proxy'是有效的,第二个不是有效的语法。

所以问题是:

如何仅一次拉动即可取消设置http.proxy?

Sri*_*hna 1

对此的最佳解决方案是编写两个批处理文件,其中一个是代理设置,另一个是取消设置代理的位置。在拉取请求之前,您可以根据需要运行批处理文件。

您可以在 git bash 中使用以下命令设置 Git 代理。为 HTTP 和 HTTPS 代理设置。

git config --global http.proxy http://username:password@proxy.server.com:8080
git config --global https.proxy http://username:password@proxy.server.com:8080

//Replace username with your proxy username
//Replace password with your proxy password
//Replace proxy.server.com with the proxy domain URL.
//Replace 8080 with the proxy port no configured on the proxy server.
Run Code Online (Sandbox Code Playgroud)

要取消设置 Git 代理,请在 Git bash 中运行以下命令。git config --global --unset http.proxy git config --global --unset https.proxy

查看如何配置 Git 代理如何取消设置 Git 代理了解更多详细信息