BardYoren
BardYoren

Reputation: 171

Git suddenly won't authenticate to GitHub automatically

I wanted to push to a remote repo on GitHub. I typed git pull origin main exactly as I have a hundred times but I get the error:

fatal: Unable to persist credentials with the 'wincredman' credential store.

I've tried everything I could find. I unset my credential manager, deleted old credentials in Windows Credential Manager, tried creating a PAT. I finally managed to successfully pull/push using the PAT, but now I have to manually input my username and PAT every single time.

I have no idea what happened, but I would love to be able to push/pull from remote without needing to login.

Upvotes: 15

Views: 26053

Answers (7)

Momin
Momin

Reputation: 446

For visual studio scenario, following steps worked for me.

Open Visual Studio as administrator
Go to Git menu option
Click on Open Command Prompt option
A command prompt should open with C:/<username> or C:/<username>/<repo name> Type and execute command

git config --global credential.credentialStore dpapi

After this try to do any pull or push operation of a mapped repo will prompt for fresh login into visual studio and once successfully logged in, repo can be pulled.

Prior to doing above, I had tried following and it did not work.

  1. Visual Studio and Machine restart
  2. Manually adding Windows Credentials for visualstudio.com
  3. Adding credentials using GitBash

Upvotes: 0

PadmaLatha Jagana
PadmaLatha Jagana

Reputation: 1

git config --global credential.credentialStore dpapi and after that type git push command . It works for me. along with Delete the existing git credential in Windows Credential Manager.

Upvotes: 0

Rahuman Khan
Rahuman Khan

Reputation: 1

Removed credential from windows credential manager, but still problem was not resolved. There was an pending update in Visual Studio Installer for VS2017. After updating VS 2017, I was able to connect with credential manager.

Upvotes: 0

David Liang
David Liang

Reputation: 21476

The same issue happened to me when I was trying to pull any incoming on the master branch using the Git Repository window in Visual Studio Professional 2022 (64-bit) Version 17.4.2.

Here is what worked for me:

  1. Delete the existing git credential in Windows Credential Manager
    1. Type "Credential Manager" in Windows search bar
    2. Select "Windows Credentials"
    3. You should see a list of Generic Credentials
    4. If you see one that starts with "git:https://dev.azure.com/{your_organization}", expand it by clicking the down arrow, and click "Remove"
  2. Close any Visual Studio you have opened
  3. Right click Visual Studio and do "Run as administrator"
  4. Now when you try to do a Pull again, it should prompt you the login screen
  5. After successfully logging in, a git credential should be recorded in Windows Credential Manager

Upvotes: 4

brandon s
brandon s

Reputation: 71

I had this problem.

I followed the above advice David Liang and BardYolen gave on this post along with some additional stack overflows post and none of it worked.

I eventually had to launch visual studios installer. Modify my versions individual to include GitFor windows by going to individual components and checking the box next to "git for windows". Then, I updated my visual studios.

After that everything seemed to work.

I am unsure if I had git for windows in visual studios before that and it just got deleted somehow or if I never had it and something got updated to removed my access to used git without it.

Upvotes: 0

Priyanka Jadhav
Priyanka Jadhav

Reputation: 571

The same issue happened to me when I push file from visual studio to github. When you will get Unable to persist credentials with the 'wincredman' credential store this type of error. Just type this command on command prompt

git config --global credential.credentialStore dpapi and after that type git push command . It works for me.

Upvotes: 46

BardYoren
BardYoren

Reputation: 171

Honestly not really sure what I did to fix things. I deleted all of the credentials set in git/Windows Credential Manager/etc... Tried to pull from remote in VS Code and it made me log in to GitHub. Now everything is back to working as expected. It seems like I can only push/pull from VS Code the way that I want. I guess it works.

Upvotes: 2

Related Questions