不知何故,在Win7下使用git通过shadowsocks代理克隆github.com上的仓库总是失败,而网上也没有找到类似问题。百思不得姐。

网络环境

通过宾馆的Wifi连接Internet,网络正常(可以访问baidu);本地的shadowsocks代理服务正常(默认的1080端口),工作正常(可以访问google)。

git代理配置

尝试了以下两种代理配置,均无法从github.com克隆仓库。

方式1:指定仅对特定网站(github.com)使用代理

1
$ git config --global http.https://github.com.proxy 'socks5://127.0.0.1'

设置后,~/.gitconfig配置文件中有关代理部分的内容如下:

1
2
[http "https://github.com"]
proxy = socks5://127.0.0.1:1080

尝试克隆qtcreator仓库,结果如下:

1
2
3
$ git clone https://github.com/qt-creator/qt-creator.git
Cloning into 'qt-creator'...
fatal: unable to access 'https://github.com/qt-creator/qt-creator.git/': SSL: no alternative certificate subject name matches target host name 'github.com'

方式2:指定全局使用代理

1
2
$ git config --global http.proxy 'socks5://127.0.0.1:1080'
$ git config --global https.proxy 'socks5://127.0.0.1:1080'

设置后,~/.gitconfig配置文件中有关代理部分的内容如下:

1
2
3
4
[http]
proxy = socks5://127.0.0.1:1080
[https]
proxy = socks5://127.0.0.1:1080

该配置的测试结果与之前相同。

若将socks5代理转为http代理(使用privoxy-3.0.26),git使用代理正常,克隆成功。另外,测试了一下关闭http.sslVerify选项(通过git config设置为false),似乎无效果。