Separate credentials for two accounts on Windows

I recently created a second GitHub account two separate my work and my private projects (before, I only had the work account). I use https in combination with the Windows credential storage. To automatically select the correct account, I store my private account info in ~/.gitconfig and the work account info in ~/work/.gitconfig as suggested here.

Unfortunately, when I try to push changes in my private repositories, I get the following error:

$ git push
remote: Permission to privateuser/privaterepo.git denied to workuser.
fatal: unable to access '': The requested URL returned error: 403

I set the remote URL to git remote set-url origin like suggested here. Pushing in my work repos still works fine. And when I type git config in my private/work repos, I get my private/work username, respectively - as it should be.

What’s the problem with the new private repositories? Why does git still think I’m workuser, when I try to push to my private repos? Does it have to do something with the Windows Credential storage, which I used to store my work credentials? It never asked for the password of my private account…

I tried to get help on stackoverflow, but it seems nobody can answer the question :frowning:

You could look at the credentials management from Windows. You can find that by going to the Control Panel, then searching for “credentials”.

I believe that if Git can’t find any credentials stored there it will just ask you for user/password every time.


Yes, deleting my github credentials from the Windows credential manager let to github asking me again for my account info, when it did the next push. But it it then uses these credentials for all further github interactions, i.e., not allowing two access to two different github accounts.

I tried manually adding generic credentials git: and git:, but they were simply ignored and didn’t change anything. Even though, I set git remote set-url origin and git remote set-url origin

1 Like

I guess it happens because Windows credential manager stores a password by domain and the domain for both git: and git: is the same. It seems that the only solution is to remove windows credentials manager

git config --system--unset credential.helper

and either make git prompt for credentials each time or use store helper to remember project specific credentials:

git config credential.helper store
git config credential.${remote}.username yourusername
git config credential.${remote}.password youruserpassword

you can read more about store here


“It seems that the only solution is to remove windows credentials manager”

git config --system--unset credential.helper

I followed the above advice and after so many different attempts to configure git store to recognize two github accounts, which I understand can be done, found this article on getting windows credential manager to recognize two seperate accounts from the same url. 

git config --global true

Haven’t tried it yet, but as soon as I reset git to use windows credential manager again I will. 

Any ideas on how to reverse, git config --system–unset credential.helper? Other than uninstalling reinstalling git for windows. 


What you need to do is to create a new ssh key for your second Github account because by default git is using the key from your first Github account and when you try to push from the second account you will get remote: Permission to privateuser/privaterepo.git denied to workuser. workeruser in this case is your first Github account’s username. So you cant push to your second Github account using the first Github account’s username. Follow this link for help.

Can you tell me ? How Can remove credential.helper manager from git?