Search code examples
gitvisual-studio-2019

Visual Studio 2019 doesn't remember GitHub credentials


With a clean install of Visual Studio 2019 (Community Edition), every push to a GitHub repo asks for credentials. When I paste in my access token the push succeeds, but I'm asked again on the next push.

enter image description here

Git credential helpers are supposed to cache your credentials, and Visual Studio 2019 uses the Git Credential Manager (GCM) by default. (I see "GCM" in Git > Settings > Source Control > Git Global Settings > Credential Helper. I see credential.helper=manager in git config --list.)

No luck with the solutions in this question (which is about Visual Studio Code) -- same behavior if I set the credential helper to store or cache or wincred or manager-core.

Same behavior if I run from the command line:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd\git.exe" push

(This worked fine for years until I installed Visual Studio 2022, uninstalled it, and reinstalled Visual Studio 2019.)

I've spent half a day on this. Almost ready to go back to SSL (ugh).

Any ideas?


Solution

  • Be sure to check the git config at each level (project, global, and system) to make sure a setting is to be what you expect.

    • project - The git config in your current repository directory. The config file will be found in [repository]/.git/config.
    • global - The git config in your home directory. The config file will be found in ~/.gitconfig.
    • system - The git config in your git install directory. The config file will be found in C:\Program Files\Git\etc\gitconfig for Windows.

    You should be able to check settings from the command line as well for each of the different levels.

    # effective settings (if set in project, global, or system)
    $ git config credential.helper
    
    # project settings (if set)
    $ git config --local credential.helper
    
    # global settings (if set)
    $ git config --global credential.helper
    
    # system settings (if set)
    $ git config --system credential.helper