How to Set and Remove Git Configuration Proxy Settings

Post Time: Mar 3, 2025
Update Time: Jul 28, 2025

Introduction

Git allows users to configure proxy settings for accessing repositories through a proxy server. This is particularly useful when working in restricted network environments. This guide covers how to configure and remove proxy settings for both HTTPS and SSH connections in Git.

Setting Up a Git Proxy

1. Configuring Proxy for HTTPS Connections

Git uses the http.proxy setting to configure an HTTP or HTTPS proxy.

Step-by-Step Guide

  1. Open a terminal or command prompt.

  2. Set the proxy for Git using the following command:

Copy
  • Replace proxyuser with your proxy username.

  • Replace proxypassword with your proxy password (if required).

  • Replace proxy.server.com with the proxy server address.

  • Replace port with the port number.

  1. If using an HTTPS proxy, use:
Copy

Verifying Configuration

Run the following command to check if the proxy is set:

Copy

If set correctly, it will display the proxy address.

2. Configuring Proxy for SSH Connections

Git uses SSH for secure connections. To use a proxy for SSH, modify the SSH configuration file.

Step-by-Step Guide

  1. Open the SSH config file (create it if it doesn’t exist):
Copy
  1. Add the following lines:
Copy
  • Replace proxy.server.com and port with your proxy details.

  • For Windows, use:

Copy
  1. Save and exit the file.

  2. Test the SSH connection:

Copy

Removing Git Proxy Settings

1. Removing Proxy for HTTPS

To remove the proxy setting for HTTP and HTTPS:

git Copy

To verify removal:

Copy

If nothing is returned, the proxy has been removed successfully.

2. Removing Proxy for SSH

  1. Open the SSH config file:
Copy
  1. Locate and remove or comment out the ProxyCommand lines.

  2. Save the file and test:

Copy

Troubleshooting

1. Git Proxy Not Working?

  • Ensure the proxy server details are correct.

  • If using authentication, check for special characters in the password (encode them if necessary).

  • Test connectivity with:

Copy

2. Unable to Remove Proxy?

  • Use --system instead of --global if the setting is applied system-wide:
Copy
  • Manually check the Git config file:
Copy

and remove proxy entries.

Conclusion

Setting and removing a proxy in Git is essential for working behind firewalls or corporate networks. By following this guide, you can configure and troubleshoot proxy settings for both HTTPS and SSH connections efficiently.

If you have any issues, verify your network settings and proxy credentials.

For more information, you can also read the chinese page as follow: https://gist.github.com/laispace/666dd7b27e9116faece6

Related articles

Consent Preferences