本文仅仅适合有【科学】的的用户 , 把下方的 127.0.0.1:7890 替换为 你自己的

背景

在使用了科学的情况下, 浏览器访问 github 速度正常

但是在 push、 pull 代码的时候,速度特别慢,慢的要死

哪怕设置了 proxy

git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

就算这样设置后,还是不行, 为什么呢?

经过研究后发现, 上方的设置,似乎只针对 https://github.com/xxx/yyy.git 这种 https 开头 的仓库 起作用

而我用的这个仓库,刚好是 ssh协议的 [email protected]:xxx/yyy.git (git 开头的)

针对 [email protected]:xxx/yyy.git 这种,git 开头的仓库, 需要通过下方的方式,来走【科学】渠道

编辑 ~/.ssh/config

# GitHub.com
Host github.com
  ... # 其他配置
  ProxyCommand nc -X connect -x 127.0.0.1:7890 %h %p

总结(下面两项同时设置最完美)

1、针对https开头的的仓库

git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

2、针对git开头的仓库

 
Host github.com
  ... # 其他配置
  ProxyCommand nc -X connect -x 127.0.0.1:7890 %h%p