如何绕过我使用git config设置的http.proxy? [英] How to bypass the http.proxy that I have set using git config?

查看:791
本文介绍了如何绕过我使用git config设置的http.proxy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我所拥有的工作计算机,有时会随身携带在家里.现在,我们有一个代理服务器在工作,并且我已经配置git以通过执行git config --global http.proxy http://proxy.company.com来使用它.因此,当我回到家里时,不需要代理,因此需要取消http.proxy的设置.如果我需要偶尔做一次,这没关系,但是现在我每天都需要这样做:设置代理,当我上班时,回家并取消设置代理,第二天再次将其设置为工作.

The work computer that I have, I occasionally carry it at home. Now, we have a proxy server at work, and I have configured git to use it by doing git config --global http.proxy http://proxy.company.com. So when I get back at home, I do not require a proxy, so I need to unset the http.proxy. This is okay if I have to do it once in a while, but right now I need to do this every day: set the proxy, when I get to work, go home and unset the proxy, next day set it at work again.

我需要什么

一种绕过已设置的http.proxy的方法,在每个命令中分别 .类似于--no-proxy选项:

A way to bypass the http.proxy that has been set, individually in every command. Something like a --no-proxy option:

git --no-proxy pull

不是想要在每个命令中指定代理,例如:

I do not want to specify the proxy in every command, like:

git --proxy=http://proxy.company.com

因为我在工作中做的比在家中做的更多.

because I do more gitting at work than I do at home.

推荐答案

您可以完全按照您的要求进行操作

You can either do exactly what you asked by using

git -c http.proxy= clone https://github.com/foo/bar.git

这会将此命令的代理设置为空值,因此不使用代理.

This will set the proxy to an empty value for this command and thus not use a proxy.

如果不是克隆,而是获取,推送,拉取等操作,则还可以在存储库中添加两个远程服务器,然后相应地设置remote.<name>.proxy.然后,您在工作中使用一个遥控器,在家里使用另一个遥控器.由于提交是相同的,即使它位于不同的远程跟踪分支上,您也不必下载两次提交.

If it is not about cloning, but about fetching, pushing, pulling and so on, you can also add two remotes to your repository and then set remote.<name>.proxy accordingly. Then you use one remote at work and the other at home. As the commits are the same you should not have to download a commit twice even if it is on different remote tracking branches.

这篇关于如何绕过我使用git config设置的http.proxy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆