GIT Multiple Credentials On Windows - gecko-8/devwiki GitHub Wiki

Up

Problem

If your using GIT on Windows with HTTPS connections there's a good chance your GIT credentials are being stored in the Windows Credentials manager. By default, the Windows Credentials manager will only store a single user credential for a particular GIT provider (Github, GitLab, CodeCommit, etc.). If you have multiple accounts on that provider this will lead to access errors.

Fix

  1. Open the Windows Credential Manager by running the Credential Manager app from the start menu.
  2. Click on Windows Credentials
  3. Under Generic Credentials, remove all credentials for the provider you wish to fix.
    1. Click on the credential
    2. Click Remove
    3. Click Yes in the confirmation popup
  4. Open a terminal
  5. Enter the command
    git config --global credential.<url of provider's git host without the https://>.useHttpPath true
    
    e.g. Github would be
    git config --global credential.github.com.useHttpPath true
    
    e.g. CodeCommit would be (note that if you have repos in multiple regions, you will need to execute the command for each)
    git config --global credential.git-codecommit.ca-central-1.amazonaws.com.useHttpPath true
    
  6. Now use GIT as normal. The Credential Manager should now store credentials for each repository with the full path instead of just the provider part so you can have multiple entries (for different accounts)