Configuring Git Proxy
Issue
In China, the speed of git clone
and git pull
is often too slow.
Solution
1. Configuration within Proxy Software
- In your proxy software, enable the option for "Allow connections from local network."
- Take note of the port number (e.g., 1080).
- Activate "Global Mode."
2. Configuring Global Git HTTP Proxy
git config --global http.proxy http://127.0.0.1:【Port Number】
git config --global https.proxy https://127.0.0.1:【Port Number】
# For example:
git config --global http.proxy http://127.0.0.1:10808
git config --global https.proxy https://127.0.0.1:10808
# If the above doesn't work, try using the socks5 protocol:
git config --global http.proxy socks5://127.0.0.1:【Port Number】
git config --global https.proxy socks5://127.0.0.1:【Port Number】
# To proxy only GitHub without affecting domestic repositories (not recommended for those unfamiliar with configuration files):
git config --global http.https://github.com.proxy https://127.0.0.1:【Port Number】
git config --global https.https://github.com.proxy https://127.0.0.1:【Port Number】
# To proxy only GitLab without affecting domestic repositories (not recommended for those unfamiliar with configuration files):
git config --global https.https://https://gitlab.com.proxy https://127.0.0.1:1080
Configuration on Ubuntu:
Viewing Configuration File Paths
Reverting Changes
If you no longer wish to use the proxy, you can undo the changes using the following method:
References and Acknowledgments
Original: https://wiki-power.com/ This post is protected by CC BY-NC-SA 4.0 agreement, should be reproduced with attribution.
This post is translated using ChatGPT, please feedback if any omissions.