Linux - How to Remove Git Credentials

2019-03-11 07:33发布

问题:

I ran

git config credential.helper store

and ran

git push origin master

where I entered my credentials and they were saved.

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

How can I do this?

回答1:

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

git config --global --unset credential.helper


回答2:

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.



回答3:

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



回答4:

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



回答5:

None of the above solutions worked for me. I revoked the access by deletion of the token I had generated the machine.

I logged into GitHub webpage went to: click picture > settings > Developer settings > Personal access tokens > delete the token for that particular machine