You now can use an encrypted .netrc (with gpg).
A new read-only credential helper (in contrib/) to interact with the .netrc/.authinfo files has been added.
That script would allow you to use gpg-encrypted netrc files, avoiding the issue of having your credentials stored in a plain text file.
Files with the .gpg extension will be decrypted by GPG before parsing.
Multiple -f arguments are OK. They are processed in order, and the first matching entry found is returned via the credential helper protocol.
When no -f option is given, .authinfo.gpg, .netrc.gpg, .authinfo, and .netrc files in your home directory are used in this order.
git config credential.helper '$shortname -f AUTHFILE1 -f AUTHFILE2'
(Note that Git will prepend "git-credential-" to the helper name and look for it
in the path.)
# and if you want lots of debugging info:
git config credential.helper '$shortname -f AUTHFILE -d'
#or to see the files opened and data found:
git config credential.helper '$shortname -f AUTHFILE -v'
Update late 2012, With git version 1.7.9+: This answer from Mark Longair details the credential cache mechanism which allows you to not store your password in plain text as shown below.
If you are using Windows 7
run the cmd
setx HOME %USERPROFILE%
then go to it
and make a file called '_netrc'
Note: for Windows, you need a '_netrc' file, not a '.netrc'.
Its content is quite standard (Replace the with your values):
Luke mentions in the comments:
Using the latest version of msysgit on Windows 7, I did not need to set the HOME environment variable. The _netrc file alone did the trick.
This is indeed what I mentioned in "Trying to install github, .ssh dir not there":git-cmd.bat included in msysgit does set the %HOME% environment variable:
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%
believes in the comments that "it seems that it won't work for http protocol"
However, I answered that netrc is used by curl, and works for http protocol, as shown in this example (look for 'netrc' in the page): . Also used with http protocol here: "_netrc/.netrc alternative to cURL".
A common trap with with netrc support on Windows is that git will bypass using it if an origin https url specifies a user name.
@Bernd: the HOME environment variable is important, because it isn't defined by default on Windows. You can set that variable to whatever directory you want (it doesn't have to be C:\users\mylogin): for example, at work, I set it to my private remote disk associated with my Windows account, which allows me to switch desktops without having to lose my .ssh or _netrc settings.
@Bernd: check also if your Git repo is on a LAN or WAN (internet) server. You may need to define an http.proxy in your environment variables. Or, on the contrary, to add your server to a no_proxy variable, to avoid trying to access a LAN server over WAN.
Excelent - this is working! I created the file and set the HOME environment variable and it works!
What is the name and value for the environmental variable? Could you be a little more specific VonC