How to remove cached credentials from Git?

As he did not give any flag as global or local or system, it would take local by default, so the correct way is to move to the respective folder(repository) and type this command

git config --local --unset credential.helper

or

git config --unset credential.helper

Reference: https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-config


Your credentials are stored in the file you (or the thing using git credential-store) specified when you (or it) ran the command, as described in the documentation. The default is $HOME/.git-credentials. You should be able to open this file in your editor and edit it, or simply remove it entirely.

Note that you may also want to change the credential helper so that these are not stored again. See the git credential-cache documentation as well, for instance.


Run the following command in the terminal to remove your credentials stored in the cache

git config --global --unset credential.helper

If you would like the daemon to exit early, forgetting all cached credentials before their timeout, you can issue an exit action, run the following command.

git credential-cache exit