Working with git behind proxy Working with git behind proxy windows windows

Working with git behind proxy


Update February 2016:

With git 2.8 (March 2016), you don't have to embed in clear text your password in the url.

See commit 372370f, commit ef97639 (26 Jan 2016) by Knut Franke (``).
Helped-by: Junio C Hamano (gitster), Eric Sunshine (sunshinebell28), and Elia Pinto (devzero2000).
(Merged by Junio C Hamano -- gitster -- in commit 30f302f, 03 Feb 2016)

http: use credential API to handle proxy authentication

Currently, the only way to pass proxy credentials to curl is by including them in the proxy URL. Usually, this means they will end up on disk unencrypted, one way or another (by inclusion in ~/.gitconfig, shell profile or history).
Since proxy authentication often uses a domain user, credentials can be security sensitive; therefore, a safer way of passing credentials is desirable.

If the configured proxy contains a username but not a password, query the credential API for one. Also, make sure we approve/reject proxy credentials properly. So:

In addition to the syntax understood by curl, it is possible to specify a proxy string with a user name but no password, in which case git will attempt to acquire one in the same way it does for other credentials.
See gitcredentials for more information.
The syntax thus is:

[protocol://][user[:password]@]proxyhost[:port]

This can be overridden on a per-remote basis; see remote.<name>.proxy.


Update Oct. 2015

Since git 1.8.0 and commit 7bcb747, the default Windows credential helper is wincred, a git credential helper that interface with Windows' Credential Manager.

 git config --global credential.helper wincred

Original answer (March 2013):

You can use a credential helper (git1.7.9+) like git-credential-winstore on Windows, in order to store your credentials.
You will declare it with a 'git config --global credential.helper winstore'.
You can then declare your proxy without putting your username and password:

git config --global http.proxy http://proxy.server.com:8080

(although I prefer using environment variables http_proxy and https_proxy)

See also "git: 'credential-cache' is not a git command"