道高一尺
疫情呆在家里,发现墙又高了不少, Clone Github 仓库时,速度极慢。
$ git clone [email protected]:docsifyjs/docsify.git
Cloning into 'docsify'...
remote: Enumerating objects: 8846, done.
Receiving objects: 1% (89/8846), 44.01 KiB | 1024 bytes/s
Receiving objects: 2% (177/8846), 68.01 KiB | 2.00 KiB/s
使用 SSH 方式安全性更高,不用输入帐户密码,只需配置 SSH keys 即可
魔高一丈
如果使用 HTTPS 的连接方式,可以很方便设置 http.proxy
git config --global http.proxy http://127.0.0.1:23333
git config --global --unset http.proxy
而 SSH 的连接需要配置 .ssh
目录下的 config
文件
Host github.com
User git
Port 22
Hostname github.com
IdentityFile "C:\Users\Mather\.ssh\id_rsa"
ProxyCommand connect -S 127.0.0.1:23333 -a none %h %p
TCPKeepAlive yes
Host ssh.github.com
User git
Port 443
Hostname ssh.github.com
IdentityFile "C:\Users\Mather\.ssh\id_rsa"
ProxyCommand connect -S 127.0.0.1:23333 -a none %h %p
TCPKeepAlive yes
看到速度已经起飞
$ git clone [email protected]:docsifyjs/docsify.git
Cloning into 'docsify'...
remote: Enumerating objects: 8846, done.
remote: Total 8846 (delta 0), reused 0 (delta 0), pack-reused 8846
Receiving objects: 100% (8846/8846), 16.68 MiB | 2.21 MiB/s, done.
Resolving deltas: 100% (5639/5639), done.
参考文档
SSH Proxy Command -- connect.c - wiki