问题描述
是否可以将git配置为仅针对特定域使用代理?
我想使用我们的公司代理来访问Github,访问我们自己的内部git仓库。
我使用bower,它需要在我们的防火墙和github中都需要物品,所以我不能这样做项目设置。它需要是某种全局配置选项。任何想法?
我通常使用环境变量:
-
http_proxy = http:// username:password @ proxydomain:port
-
https_proxy = http:// username:password @ proxydomain:port
访问GitHub仓库。
注意:
-
http_proxy
和https_proxy
必须使用http://
代理网址(无https://
)。 - 始终使用
proxydomain
(不要依赖它的简称)
但是对于内部回购,我所要做的就是定义并导出一个环境变量:
-
no_proxy = .my.company,localhost,127.0.0.1,:: 1
,用于访问任何回购机智h地址像myrepo.my.company
或localhost。
您可以定义 NO_PROXY
或 no_proxy
,这并不重要。
但为了防万一,我总是设置 HTTP_PROXY
, HTTPS_PROXY
, http_proxy
, https_proxy
, NO_PROXY
和 no_proxy
。
Is it possible to configure git to use a proxy only for specific domains?
I'd like to use our corporate proxy to access Github but leave it off for accessing our own internal git repos.
I'm using bower and it needs to require items both within our firewall and on github so I can't do this as a per project setting. It needs to be some kind of global configuration option. Any thoughts?
I usually use the environment variables:
http_proxy=http://username:password@proxydomain:port
https_proxy=http://username:password@proxydomain:port
That is picked up by git when accessing GitHub repo.
Note:
- both
http_proxy
andhttps_proxy
must use thehttp://
url of the proxy (nohttps://
). - always use the fqn (full qualified name) of
proxydomain
(don't rely on its short name)
But for internal repo, all I have to do is define and export one more environment variable:
no_proxy=.my.company,localhost,127.0.0.1,::1
, for accessing any repo with an address likemyrepo.my.company
or localhost.
You can define NO_PROXY
or no_proxy
, it doesn't matter.
But just in case, I always set HTTP_PROXY
, HTTPS_PROXY
, http_proxy
, https_proxy
, NO_PROXY
and no_proxy
.
这篇关于只使用代理服务器的某些git网址/域名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!