This page looks best with JavaScript enabled

Several Ways to Access GitHub from China

 ·  ☕ 1 min read

For well-known reasons, accessing Github from a network environment in China is either blocked or very slow. This article provides several ways to get around it.

1. Download Using a Github Mirror

Just prepend a Proxy address to the GitHub repository; the way different Mirrors are concatenated may vary. The example below pulls the https://github.com/shaowenchen/scripts repository.

1
git clone https://github.com/shaowenchen/ops

2. Import the GitHub Project via Gitee

You can refer to the documentation: GitHub仓库快速导入Gitee及同步更新, to import a GitHub repository into Gitee.

Then pull the code using the Gitee address.

3. Configure the Github Host Address

Open https://www.ipaddress.com/ and look up the IP address of github.com

Edit the local /etc/hosts file and add the following content:

1
140.82.112.4 github.com

After that you can pull the code, but the speed will not be very fast, because Github uses US IPs.

4. Configure a Command-Line Proxy

If you have a usable proxy service, just configure the proxy in your local Terminal.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Proxy
function proxy_off(){
    unset http_proxy
    unset HTTP_PROXY
    unset https_proxy
    unset HTTPS_PROXY
    echo -e "已关闭代理"
}
function proxy_on(){
    export http_proxy="http://127.0.0.1:1087";
    export HTTP_PROXY="http://127.0.0.1:1087";
    export https_proxy="http://127.0.0.1:1087";
    export HTTPS_PROXY="http://127.0.0.1:1087";
    echo -e "已开启代理"
}

WeChat Official Account
WRITTEN BY
WeChat Official Account