A Proxy to Make Github Access Fly

less than 1 minute read

It is well known that, accessing github in China is a torture, cloning a github repository takes too much time, especially for big project like linux kernel, therefore hunsh created a great project called gh-proxy.

Now let’s get started with the clone operation:

git clone https://gh.api.99988866.xyz/github.com/armbian/build.git
Cloning into 'build'...
warning: redirecting to https://github.com.cnpmjs.org/armbian/build.git/
remote: Enumerating objects: 119, done.
remote: Counting objects: 100% (119/119), done.
remote: Compressing objects: 100% (92/92), done.
Receiving objects:  19% (11025/57413), 29.93 MiB | 1.13 MiB/s

Form the above results we see there is an warning and the speed is not 20.00 KiB/s any more.

Cloning one repo is easy with this method, but if you are using a build system, such as buildroot or armbian build system, you don’t want to change every repo URL, url.<base>.insteadOf can make your life much easier, config with

git config --global url."https://gh.api.99988866.xyz/github.com/".insteadof https://github.com

or append the following to your $HOME/.gitconfig:

[url "https://gh.api.99988866.xyz/github.com/"]
	insteadof = https://github.com

All credit goes to hunsh.