Monday, January 16, 2012

Git - How to use .netrc file on windows to save user and password

Reference: Git - How to use .netrc file on windows to save user and password


Is it possible to use a .netrc file on windows when I'm using Git to clone a remote repository with http and user - password?


Answer:

You must define:
  • environment variable %HOME%
  • put a _netrc file in %HOME%
If you are using Windows 7
run the cmd type this:
setx HOME %USERPROFILE%
and the %HOME% will be set to 'C:\Users\"username"'
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:
machine hostname1
login login1
password password1
machine hostname2
login login2
password password2

No comments: