Contents
  1. 1. Solution2: Setting Proxy
    1. 1.1. Setting Http Proxy for git clone by HTTPS URL
    2. 1.2. or Setting SSH Proxy for git clone by SSH URL
  2. 2. Solution1: Switching from using ssh to https
  3. 3. other Improvements
  4. 4. References

Solution2: Setting Proxy

First of all, using US proxy instead of others, like HK.

Setting Http Proxy for git clone by HTTPS URL

setting http proxy for git

1
2
3
git config --global http.proxy socks5h://127.0.0.1:1080
# or
git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080

or temporarily setting HTTP proxy for your terminal

1
2
3
4
// linux
export ALL_PROXY=socks5://127.0.0.1:1080
// windows
set ALL_PROXY=socks5://127.0.0.1:1080

Test Case

Before Setting Proxy

1
2
3
4
5
6
git clone https://github.com/mybatis/mybatis-3.git mybatis-clone-test
Cloning into 'mybatis-clone-test'...
remote: Enumerating objects: 397085, done.
remote: Counting objects: 100% (195/195), done.
remote: Compressing objects: 100% (79/79), done.
Receiving objects: 4% (15884/397085), 5.25 MiB | 197.00 KiB/s

After Setting Proxy

1
2
3
4
5
6
git clone https://github.com/mybatis/mybatis-3.git mybatis-clone-test
Cloning into 'mybatis-clone-test'...
remote: Enumerating objects: 397085, done.
remote: Counting objects: 100% (195/195), done.
remote: Compressing objects: 100% (79/79), done.
Receiving objects: 14% (55592/397085), 18.63 MiB | 3.16 MiB/s

or Setting SSH Proxy for git clone by SSH URL

Add following content to your git SSH config file:

1
2
3
4
...
User git
Port 443
ProxyCommand "C:\Program Files\Git\mingw64\bin\connect.exe" -S 127.0.0.1:1080 %h %p
  • git SSH config file path
    • Windows: ~/.ssh/config
    • Linux: ~/.ssh/config
  • git connect program
    • Windows: {git_install_path}\Git\mingw64\bin\connect.exe
    • Linux: /usr/bin/nc

Solution1: Switching from using ssh to https

Using ssh: about 20 KiB/s

1
2
git clone git@github.com:xxx/xxx.git
Receiving objects: 0% (309/396867), 172.01 KiB | 26.00 KiB/s

Using https: about 400 KiB/s

1
2
git clone https://github.com/xxx/xxx.git
Receiving objects: 100% (396867/396867), 113.49 MiB | 402.00 KiB/s, done.

other Improvements

1
2
git config --global http.postbuffer 524288000
git config --global credential.helper "cache --timeout=86400"

References

[1] GitHub 加速终极教程

Contents
  1. 1. Solution2: Setting Proxy
    1. 1.1. Setting Http Proxy for git clone by HTTPS URL
    2. 1.2. or Setting SSH Proxy for git clone by SSH URL
  2. 2. Solution1: Switching from using ssh to https
  3. 3. other Improvements
  4. 4. References