Today I would like to share with you my experience of setting up a global proxy server for git. As a senior programmer, I know that network problems when using git is a big headache, especially when accessing domestic repositories in China, due to well-known reasons, the download speed is often very slow or even not connected. However, with the global proxy server settings, these problems can be solved, let's take a look at how to do it!
Setting up a git proxy
First, we need to configure a global proxy server in the git client. Here is an example for Windows, open the git command line tool and enter the following command:
git config --global http.proxy http://代理服务器地址:端口号
git config --global https.proxy https://代理服务器地址:端口号
Among them, the proxy server address and port number need to be filled in according to the specific situation.
Cancel git proxy
If you need to cancel the proxy, it's also easy, just enter the following command:
git config --global --unset http.proxy
git config --global --unset https.proxy
Verify proxy settings
To verify that the agent is set up successfully, you can view the current git configuration information with the following command:
git config --global --get http.proxy
git config --global --get https.proxy
If the set proxy server address and port number are returned, the setup is successful.
Using Proxies
After setting up the proxy, when you do git again, it will automatically connect through the proxy server, thus speeding up the download speed and stability.
summarize
By setting up a global proxy server, we can easily solve the network problems encountered when git is used in China, thus improving work efficiency. I hope this experience can help you.