How to configure Git proxy?

If you are working in a corporate company all the internet requests usually go through the corporate firewall. The Git will simply throw one of these errors “Request timeout” or “unable to access” or “Couldn’t resolve host” whenever you try to access git fetch, pull or push. To solve this issue, we need to configure the git proxy. Just open up the Git Bash or Powershell on your computer and then add the git config proxy user commands of git as shown below.

Configure Git proxy

According to the official Git documentation, we need to set both HTTP and HTTPS proxy by executing the below git commands in your terminal window.

http.proxy is the proxy setting mainly used for HTTP requests and https.proxy is the proxy setting mainly used for HTTPS (Secure) requests.

git config --global http.proxy http://<username>:<password>@<proxy.server.com>:<8080>
git config --global https.proxy http://<username>:<password>@<proxy.server.com>:<8080>

// Replace <username> with your proxy username
// Replace <password> with your proxy password
// Replace <proxy.server.com> with the proxy domain URL.
// Replace <8080> with the proxy port no configured on the proxy server.

Note: Ensure to replace the dummy proxy variables with the actual proxy variables provided by your company.

How to Remove Git Proxy?

We can remove the Git Proxy globally by using the unset command on both http.proxy and https.proxy as shown below.

git config --global --unset http.proxy
git config --global --unset https.proxy

How to Verify Currently Set Git Proxy?

If you are not sure if the git proxy is configured in the system, you can verify it by running the get proxy command as shown below.

git config --global --get http.proxy
git config --global --get https.proxy

Conclusion

It is common that corporate companies to use proxy servers and the request has to go through these firewalls and servers. Often while connecting to the Git repos, you will get either “Request timeout” or “Couldn’t resolve host“. To solve the error we can configure the git proxy for both HTTP and HTTPS using the git commands as shown in our example.

Leave a Reply

Your email address will not be published.

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like
Git Remove Untracked Files

Git Remove Untracked Files

Table of Contents Hide Difference between Tracked vs. Untracked Filesgit-clean DocumentationSyntax How to Remove Untracked Files in Git? Starting with a “Dry Run”Deleting Files with the -f Option If you…
View Post