Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Resetting stored credentials from command line #99

Closed
DavidIQ opened this issue Jan 5, 2016 · 9 comments
Closed

Resetting stored credentials from command line #99

DavidIQ opened this issue Jan 5, 2016 · 9 comments
Labels
enhancement Indicates general improvement or new feature.
Milestone

Comments

@DavidIQ
Copy link

DavidIQ commented Jan 5, 2016

When doing work on enterprise-level git repositories, i.e. within the organization, many/most times the account used to access the git repositories is tied to the network login. Most organizations have a password expiration rule in place which will mean that anything using your credentials needs to be updated.

For the Git Credential Manager the only way to do this is to go into the Windows Credential Manager and either change the password there for the git instance or delete it and try to do a pull on the repository, which will then ask you for your credentials. Otherwise you'd get an authentication error from the git repository.

Another use case might be for those organizations that have "high-security" git repositories that will only work with the user's second account. In this case it would be a bit of a nuisance to be switching back and forth between the two accounts via Windows Credential Manager.

To "fix" these scenarios it would be nice for Git Credential Manager to either ask for the new credentials (scenario 1) instead of giving a full stop or for there to be a command to manually reset the credentials via the command line (scenario 2), something like gitcmw --reset.

@whoisj
Copy link
Contributor

whoisj commented Jan 5, 2016

@DavidIQ thanks, this is on the backlog for sure.

@jeremyepling to help prioritize and schedule.

@lucasmezencio
Copy link

Once it is not implemented yet.
What can I do to reset my credentials? I am having a lot of problems because of this. :(

@DavidIQ
Copy link
Author

DavidIQ commented Apr 6, 2016

You can just go to Windows Credential Manager in the control panel and either change the applicable entry under Generic Credentials or remove it.

@lucasmezencio
Copy link

@DavidIQ thanks a lot, dude! I am not a Windows user, so I did not know where to search for this. 😃

@lucasmezencio
Copy link

Sorry about my english, BTW.

@whoisj
Copy link
Contributor

whoisj commented May 7, 2016

Sorry about my english, BTW.

Hey, I understood you - and I guarantee you would not understand me in your native language. So kudos to you. 😄

@whoisj whoisj modified the milestones: vNext, v1.6.0 Jul 29, 2016
@grdnkln
Copy link

grdnkln commented Mar 4, 2020

I know this is a few years old, but this issue is the first thing to show up when you Google "git clear cached credentials command line windows".

If you are using Git, and you are using the Windows Credential Manager to cache your credentials, and you want to reset / clear them from the command line, you can do that using the CMDKEY.EXE command.

First, list all the credentials and find the one related to your Git repo:
cmdkey /list

Then, delete it:
cmdkey /delete:[target name of the credential]

If you're like me and you're running your Git commands as a different user than the one you are currently logged in to Windows as (since I have a separate Windows account for administrative tasks), you can't open the Windows Credential Manager directly. You would normally have to log out, log in as the second account, THEN open it. That's a pain. This lets you do it from a command prompt.

@barroudjo
Copy link

I know this is a few years old, but this issue is the first thing to show up when you Google "git clear cached credentials command line windows".

If you are using Git, and you are using the Windows Credential Manager to cache your credentials, and you want to reset / clear them from the command line, you can do that using the CMDKEY.EXE command.

First, list all the credentials and find the one related to your Git repo:
cmdkey /list

Then, delete it:
cmdkey /delete:[target name of the credential]

If you're like me and you're running your Git commands as a different user than the one you are currently logged in to Windows as (since I have a separate Windows account for administrative tasks), you can't open the Windows Credential Manager directly. You would normally have to log out, log in as the second account, THEN open it. That's a pain. This lets you do it from a command prompt.

Thanks, you're a lifesaver !

@kzu
Copy link

kzu commented Sep 28, 2020

I needed this very feature, so I went ahead and implemented a dotnet global tool that does this: https://www.nuget.org/packages/dotnet-gcm/

Usage:
  dotnet gcm [options] [command]

Options:
  --version         Show version information
  -?, -h, --help    Show help and usage information

Commands:
  erase    Erase a stored credential.
  get      Get a stored credential.
  store    Store a credential.

It uses the Git Credential Manager Core, so I'm not sure it would update the older "classic" from this repo though. I'm guessing it would, since the ultimate keychain APIs underneath both are likely the same.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Indicates general improvement or new feature.
Projects
None yet
Development

No branches or pull requests

6 participants