Changing Git Credentials in Windows

,

tl;dr For Windows when you need a different account.

I had to work with a new GitHub account recently and needed to add a separate account. I worked through that process and managed to get things to work with a Personal Access Token (PAT). Since I have 2FA (2 Factor Authentication) on my GitHub account, my user/password doesn’t ever work in the command line.

Once I was done, I wanted to change back. I had cloned a new repo, made a couple changes, and then when I went to push, I got:

2019-08-08 16_38_19-cmd

sjonesdkranch is the wrong account. I want to use my way0utwest account, but despite entering a new PAT, it wouldn’t save. Since I use SQL Source Control, this was a pain as the terminal access isn’t there. I googled around and eventually realized that my generic git credentials are stored in the Windows Credential Manager, not the Git config files.

This is in the Control Panel –> User Accounts –> Credential Manager (shown here)

2019-08-08 16_40_35-Credential Manager

I first went to the Web Credentials, as I saw two https://www.github.com entries. This was incorrect, because I don’t want the web, I want the git:github.com entry, which is under the Windows Credentials section.

You can see I have a lot of Git stuff, but I want the GitHub.com one.

2019-08-08 16_41_33-Credential Manager

I expanded this down and then clicked Edit.

2019-08-08 16_42_13-Credential Manager

This had been created by the PAT I’d entered awhile ago. I had saved the one I generated today in my password manager and entered it in this dialog.

2019-08-08 16_42_45-Edit Generic Credential

I saved it and my git push worked, both from the CLI and SQL Source Control.

2019-08-08 16_43_39-cmd

Good reminder. Windows, especially Win10, has started to save and use credentials in new ways and lots of software is integrating with it in those ways.

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

Share

Share

Rate