Git配置代理

命令行中进行配置

http://stackoverflow.com/questions/783811/getting-git-to-work-with-a-proxy-server

Command to use :

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
  • change proxyuser to your proxy user
  • change proxypwd to your proxy password
  • change proxy.server.com to the URL of your proxy server
  • change 8080 to the proxy port configured on your proxy server

If you decide at any time to reset this proxy and work without (no proxy):

Commands to use:

git config --global --unset http.proxy

Finally, to check the currently set proxy;

git config --global --get http.proxy

配置好之后,就可以正常进行fetch了,配置的时候,最好加上http:// 。  目前gcm还不支持不带http的,

 

https://gist.github.com/evantoli/f8c23a37eb3558ab8765

 

git config --global http.proxy sasygsha01prx11_p.asnet.accorservices.net:8080

http.proxy后面的url,最好加上http://,否则在credential manager中会报错。参考这个issue

 

TortoiseGit中进行配置

 

Bypass的使用

场景:需要使用proxy访问github,但同时又需要访问内网部署的git server。但是proxy是无法访问内网的

https://stackoverflow.com/questions/19523903/how-to-temporarily-disable-git-http-proxy

I always set:

no_proxy=.mycompany

(export if I am on Unix, or a simple set on Windows)

It is enough to bypass the proxy for all intranet url ending with ".mycompany".

在环境变量中配置no_proxy,用英文的逗号分隔开

需要注意的是,no_proxy暂时不支持通配符,比如172.31.*

 

有人提示可以使用这种方式来bypass一组ip, 

https://unix.stackexchange.com/questions/23452/set-a-network-range-in-the-no-proxy-environment-variable

1) Add each IP in full:

printf -v no_proxy '%s,' 10.1.{1..255}.{1..255};
export no_proxy="${no_proxy%,}";

 

结论

https://github.com/git-for-windows/git/issues/2074

https://curl.haxx.se/libcurl/c/CURLOPT_NOPROXY.html

1.The only wildcard available is a single * character, which matches all hosts, and effectively disables the proxy.

2.You could list them individually:

 The string consists of a comma separated list of host names that do not require a proxy to get reached, even if one is specified.

3.if you can use a domain name:

If the name in the noproxy list has a leading period, it is a domain match against the provided host name. This way ".example.com" will switch off proxy use for both "www.example.com" as well as for "foo.example.com".

多个ip的话,每个ip对应一个不同的domain,但是这些domain都是以.example.com结尾的。

4.Alternatively, you can configure `git config http.proxy ""` for all remotes in a repository, or finer-grained `git config http.<url>.proxy ""` for individual remotes (identified by their ).  这个感觉不太实用。

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(2348)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2015-03-23 通过代码来调用log4net写日志
点击右上角即可分享
微信分享提示