How to Set a Proxy for the Git Command Line Tool

If you are trying to use the git command line interface with an Internet hosted repository, such as, from within a network that requires a proxy for outbound connections, this post shows you how to configure the git CLI to use a network proxy. This post also shows you how to provide authentication credentials (username and password), if your proxy requires it. The git config command is used to set a network proxy. This command also support the --global and --local options that control whether the settings are stored globally or in the current git repository location.

Example 1: HTTP Proxy Using Default Port 80 and no Authentication

If your proxy uses the http protocol and the default port 80 and does not require authentication, you can set it with:

git config --global http.proxy

Example 2: HTTP Proxy Using Non-Default Port and Authentication

If your proxy uses a custom port, for example 8080, and requires authentication, e.g. a username and a password, you can set it like this:

git config --global http.proxy

Example 3: NTLM Proxy with Authentication and Domain

It may also be necessary to pass a domain name as part of the proxy url, e.g. when using a NTLM proxy. You can accomplish this with the below command:

git config --global http.proxy http://domain\\username:[email protected]:8080

Escaping Special Characters in the Username and Password Parameters

If the username or password contains special characters, those need to be encoded according to HTML URL encoding rules. For example, if your password is [email protected], the @ character needs to be encoded using %40.

git config --global http.proxy http://domain\\

Viewing the Current Proxy and Unsetting the Proxy

To check what the current git proxy setting is, you can use the --list option.

git config --global --list

The network proxy can be unset using the --unset option.

git config --global --unset http.proxy

For two related posts on this blog, have a look at the following links.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.