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://email@example.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