3

Is there a way to do the above (remove all stored credentials that I added/that I have access to, from the bash CLI), irrespective of how the credentials are stored?

I use many different public computers, and it would be ideal not to have to figure out how the installation of git and the credentials is working on each.

Brief google/SO searches wielded no results

josinalvo
  • 1,366
  • 13
  • 26
  • How do you usually provide credentials? I don’t think a “delete all” exists. – evolutionxbox Sep 17 '19 at 21:29
  • What do you mean by "stored credentials"? – alex Sep 18 '19 at 14:43
  • my username and password to gitlab/github – josinalvo Sep 18 '19 at 14:50
  • @evolutionxbox when prompted, by whatever mechanism prompts me. In this case, it seems it was some kind of windows storage – josinalvo Sep 18 '19 at 17:25
  • Are you prompted each time? If so doesn’t that tell you it does not save the credentials. – evolutionxbox Sep 18 '19 at 17:33
  • nope, I got one prompt and now git pull works without asking for a password. And the prompt did not feature a "do not save" option :( – josinalvo Sep 18 '19 at 18:54
  • Go to your home directory and look for `.git-credentials` file is that what you mean? Also, if you use ssh keys you could look in `.ssh` directory and just remove files there. I think each repo may also have its own overriden configs, so you take a look at each of `.git` directories in your repos. Alternatively, you can cut off clients from server by changing the credentials and/or revoking ssh keys. – Zaffy Oct 18 '19 at 15:44

3 Answers3

7

In windows 10:

go to Control Panel -> User Accounts -> Credential Manager -> Manage Windows Credentials

Search for something like git:https://github..... and remove that.

Nyzex SKB
  • 156
  • 5
0

There's no one standard way that credentials like this are stored so unfortunately there's no one way to remove them. It isn't git or bash storing them. In most cases it'll be some sort of keychain on the OS.

I'm afraid I don't use Windows so I can't help you there.

Calum Halpin
  • 1,945
  • 1
  • 10
  • 20
0

You would need a bash script (that can work, even on Windows, through a Git for Windows bash), in order to:

  • detect your OS
  • detect the credential helper (if any) set: git config credential.helper
  • remove the credentials associated to a given URL passed as parameter of that script;

For instance, see "sign out in the Git Bash console in Windows":

git credential-manager reject https://github.com

On Mac, for osxkeychain, see "Updating credentials from the OSX Keychain"

git credential-osxkeychain erase https://github.com

The point is: you need a script to automate that step for all possible credential caching mechanism. Then try again: it will prompt for user GitHub username/password.


See also git credential reject from Git 2.42 (Q3 2023)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250