Typing Git Username and Password is Lame

I set up a local Git server to serve as a central repository. Every time I push changes I have to submit my username and password and it got old real quick. I discovered that it is very easy to get around this, although what I am about to share is a little insecure as I am storing my credentials in plain text, but there are ways to secure this.

First a little background. I am using TortoiseGit as my Git client, I am on Windows 7, and my Git server is not exposed to the public internet.

To allow my credentials to be found I first ran this command:


This sets up a Home environment variable on my system that points to my user profile (see this for more info http://technet.microsoft.com/en-us/library/cc755104.aspx).

Then I create a text file named  _netrc in the root of my user profile folder (C:\Users\{yourusername}\_netrc). In the text file I list the machine name, login, and password for each Git server I want to interact with. I assume this could also work for any server that accepts HTTP credentials.

machine mycoolserver
login mysecretlogin
password mysecretpassword
machine someotherhost.com
login mysecretlogin2
password mysecretpassword2

Machine is the root name of the server you are connecting to. In my case I have a local server without a top level domain (no .com). Then you add your credentials. Like I said this is saved in plain text, so you have to be careful with this and make sure you use credentials that you don’t use on any other accounts (e.g. your bank account).

Thanks to StackOverflow and VonC for help on this:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s