10

I have cloned one of my GitHub repositories with Visual Studio Code and I have made some commits. Visual Studio Code has asked me for my GitHub password when I have done on the first commit.

I have rebooted the computer and now I can make commits as before, but Visual Studio Code does not ask for my password. It seems that the password has been stored. But this computer is not my computer and I do not want that somebody else could use my account.

How can I make Visual Studio Code forget my GitHub password?

I have tried the Git command:

git config --global --unset-all user.email

But Visual Studio Code still lets me commit without asking.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user2178228
  • 143
  • 1
  • 1
  • 5
  • I believe `user.email` only controls the email that git commits with. Try [clearing your auth](https://stackoverflow.com/a/15382950/5767783) instead? – Clavin Jan 24 '18 at 00:34

4 Answers4

16

Check your git config credential.helper:

  • if it is manager, you would need to open your Windows Credential Manager and remove your credentials there.
    See this answer for illustration.
    Or, in command-line:

    printf "protocol=https\nhost=github.com" | git credential-manager-core erase
    
  • if it is a osxkeychain, see "Updating credentials from the OSX Keychain"

    printf "protocol=https\nhost=github.com" | git credential-osxkeychain erase
    

Reminder, those credentials (username/password) have nothing to do with your git config user.name/user.email.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Not sure if this is still current. When I ran `git config credential.helper` I received "wincred" instead of "manager". My credentials were in the windows credential manager. – Trisped Nov 29 '18 at 18:45
  • As a update, if you get "osxkeychain", you need to access your keychain in your apple computer. – Timberman Jan 28 '20 at 12:17
  • Mine returns nothing, but I am still able to push without entering a password. Does VSCode have it's own credential manager? – diatomicDisaster Apr 27 '21 at 13:07
  • @WilfridSomogyi No: maybe you are using an SSH URL, for which no credential caching is needed (since a credential cache is only for HTTPS URLs) – VonC Apr 27 '21 at 14:01
  • @VonC fairly certain I git cloned the https URL and am trying to push to the same GitHub repo if that's what you mean. Is there a way I can check – diatomicDisaster Apr 29 '21 at 10:18
  • @WilfridSomogyi In command line, go to the root folder of your repo, and type `git remote -v` – VonC Apr 29 '21 at 10:20
  • if receive "wincred", delete the file C:\Users\(username)\.git-credentials – selins sofa Sep 14 '22 at 11:03
  • @selinssofa True, and update your Git for Windows: wincred is obsolete. (replaced with [Git-Credential-Manager](https://github.com/GitCredentialManager/git-credential-manager), and its value `manager-core`) – VonC Sep 14 '22 at 11:33
6

First you need to check where the passwords are located. The credentials store or the Windows generic password.

Run this in the Visual Studio Code terminal:

  git config credential.helper

Go to and delete the file C:\Users\(username)\.git-credentials or you can simply remove the @github user rows from the text file.

Then go to Windows password: Control PanelAll Control Panel ItemsCredential Manager. The passwords are referenced to the GitHub label in generic.

Then log in into your GitHub account with your default browser. After that, restart Visual Studio Code. Clone from GitHub and follow the authorization steps from Visual Studio Code.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Pit
  • 395
  • 2
  • 11
4

For Ubuntu/GNOME Visual Studio Code users, the Credential Manager can be accessed by launching the "Passport and Keys" application. You can delete the Visual Studio Code/GitHub entry by clicking "Password", looking for the entry and delete.

Restart Visual Studio Code after, and it would ask you to sign into GitHub all over again.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
1

I'm a long time user of Visual Studio Code on both Windows and Mac. After looking into Windows Credential Manager and removing the problematic user on Windows 10, if I push from Visual Studio Code, the problematic user would return. This is of course after restarting Visual Studio Code, the system, etc, and trying multiple times. The entry would reappear in Windows Credential Manager each time.

At some point I decided to try to edit the entry instead of deleting it. This approach worked. Give that approach a try if removing the entry doesn't seem to solve the issue.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
John Vandivier
  • 2,158
  • 1
  • 17
  • 23