Push to GitHub without entering username and password every time (Git Bash on Windows)

Today I learned… how to save my GitHub username and password so I don’t have to re-enter them every time I push something to GitHub from my Windows machine.

A bit of backstory:

I recently set up git on my Windows 7 machine using Git for Windows (mysisgit). That process went smoothly and I feel right at home in my little emulator, Git Bash, using all the same commands I already know and love from my Mac.

If you’re used to using git on a Mac and have to work on a Windows machine for whatever reason, I highly recommend mysisgit.

Credential check… every time!

Everything was going great until I pushed my changes. Every push triggered a new credentials check!

$ git push origin master
Username for 'https://github.com': xyz
Password for 'https://xyz@github.com':

I don’t want to enter my GitHub username and password every time I push something.

HTTPS vs. SSH?

So I hit the Google and found this StackOverflow question, where some helpful folks say the problem results from connecting over HTTPS instead of SSH, but GitHub’s help documentation recommends connecting over HTTPS, not SSH.

I’m hesitant to disobey the word of GitHub, so instead of relying on SSH, I followed GitHub’s instructions to use a credentials helper.

Credentials Helper Setup

However… GitHub’s explanation of how to cache your password with the credentials helper aren’t very clear. They tell you to enter this line and then don’t tell you what to do next.

Here’s what I did – worked for me.

In your Git Bash window, enter this line:

$ git config --global credential.helper wincred

Now push a change to Github and enter your credentials – this is where your username and password information gets saved to the credential helper.

You won’t get any feedback telling you that, but you can confirm it worked by pushing another change. This time, you shouldn’t have to enter your credentials again.

But I have this problem on Linux!

Try this: Caching your GitHub password in Git

$ git config --global credential.helper cache


14 thoughts on “Push to GitHub without entering username and password every time (Git Bash on Windows)”

  1. Wow ! easiest solution after going through few links !
    Btw how do i stop caching or saving password (just in case if i ever need it)

    Cheers !

  2. To get a more permanent solution if you can’t be bothered with entering you credentials every now and again, even if you set the cache timeout to next year:
    git config –global credential.helper ‘cache –timeout 30758400’

    And you are not to worried about your computer being compromised see the solution in this stackoverflow answer where you create an ssh key and enter it in the github settings of your repo and never have to enter a username or password.
    http://stackoverflow.com/questions/8588768/git-push-username-password-how-to-avoid#answer-8588786

  3. Its simple than that in windows with netrc file

    John Carter@JohnCarter-PC MINGW64 ~
    $ cat ~/_netrc
    machine github.company.com
    login username
    password password

    machine github.com
    login username
    password password

    machine bitbucket.org
    login username
    password password

Leave a Reply

Your email address will not be published. Required fields are marked *