Before we start, ensure you have git_bash installed on your Windows machine. To install git_bash, you can download it from the official Git for Windows website.
Because of some known issues, direct connections to GitHub for operations like clone, pull, and push can be very slow in China. We need to set up a proxy to speed up connections to github.com.
HTTP & HTTPS Proxy Setup
Open your git_bash terminal and follow these steps to set up the proxy:
# Set the HTTP proxy
$ git config --global http.proxy "http://127.0.0.1:10808"
# Set the HTTPS proxy
$ git config --global https.proxy "http://127.0.1:10808"
You can use the following command to verify that the proxy settings have been applied correctly:
$ git config --global --get http.proxy
http://127.0.0.1:10808
$ git config --global --get https.proxy
http://127.0.1:10808
If you want to update the proxy settings, you can simply run the same commands with the new proxy address.
If you want to remove the proxy settings later, you can use the following commands:
# Remove the HTTP proxy
$ git config --global --unset http.proxy
# Remove the HTTPS proxy
$ git config --global --unset https.proxy
SSH Proxy Setup
Although HTTP and HTTPS ways are commonly used for cloning and pushing code, you might also want to set up an SSH proxy for better performance. This is especially useful if you frequently use SSH for Git operations.
Open or create the SSH configuration file at ~/.ssh/config and add the following lines:
Host github.com
Hostname ssh.github.com
User git
Port 443
IdentityFile ~/.ssh/id_rsa
ProxyCommand ProxyCommand connect -S 127.0.0.1:10808 %h %p
About hostname and port:
The ssh.github.com hostname and port 443 are used to bypass firewalls that block the default SSH port 22. This allows you to connect to GitHub over HTTPS, which is often more reliable in restrictive network environments.
If you want to use the default SSH port 22, you should change the Hostname to github.com and the Port to 22:
What is connect?
connect is a command-line utility that allows you to create a TCP connection through a proxy server. It is commonly installed with Git for Windows platforms, and you can use the following command to check where it is located:
$ which connect
/mingw64/bin/connect