Working with Git through a corporate proxy can be challenging. Here's a quick guide to configure Git proxy settings.

Configure HTTP Proxy

git config --global http.proxy http://<username>:<password>@<ip_host>:<port>

Configure HTTPS Proxy

git config --global https.proxy https://<username>:<password>@<ip_host>:<port>

Disable Proxy

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

Parameters

  • username: Proxy username
  • password: Proxy password
  • ip_host: Proxy server address
  • port: Proxy server port

Verify Configuration

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

More secure: Environment Variables

Using environment variables is a more secure method, as entering credentials directly in commands can expose them in your shell history. Instead, set your proxy credentials using environment variables:

export HTTP_PROXY=http://<username>:<password>@<ip_host>:<port>
export HTTPS_PROXY=https://<username>:<password>@<ip_host>:<port>

Note: Setting environment variables in the shell will also save them in the history, so this approach is more secure if you just set the environment variables in a file like ~/.bash_profile (if you are using bash shell).

For more details, see the official Git configuration documentation.

Security Note: Storing credentials in environment variables or in files like ~/.bash_profile is not inherently secure, as these files are stored in plain text and can be read by anyone with access to your home directory. For better security, consider using Git credential helpers or a dedicated credential manager. If you must store sensitive data in profile files, restrict access with chmod 600 ~/.bash_profile to limit who can read the file.