Coder Perfect

How to remove cached credentials from Git?


I ran:

$ git config credential.helper store

And then:

$ git push origin master

After pushing, I entered my credentials and they were saved. I read that they are stored in plaintext, and so now I want to remove my credentials from being saved and entered by default.

I’m not sure how I’m going to accomplish it.

Asked by Max Li

Solution #1

To clear your credentials from the cache, type the following command in the terminal.

git config --global --unset credential.helper

Answered by Coder

Solution #2

As mentioned in the documentation, your credentials are stored in the file you (or the thing utilising git credential-store) provided when you (or it) issued the command. $HOME/.git-credentials is the default location. You should be able to open and edit this file in your editor, or simply delete it.

It’s also worth noting that you might want to alter the credential helper to prevent these from being stored again. See, for example, the git credential-cache docs.

Answered by torek

Solution #3

Because he did not specify whether the flag should be global, local, or system, it will default to local, therefore the right method is to navigate to the appropriate folder (repository) and type this command.

git config --local --unset credential.helper


git config --unset credential.helper


Answered by Karthik Kannan

Solution #4

You can issue an exit action to have the daemon exit early, forgetting all cached credentials before their timeout, by running the following command.

Answered by Atchyut Nagabhairava

Solution #5

The unset command did not work for me, so I removed the file instead:

rm ~/.git-credentials

Answered by juan Isaza

Post is based on