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.
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.
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
None of the above solutions worked for me. I revoked the access by deletion of the token I had generated on the machine.
I logged into GitHub webpage went to:
click picture > settings > Developer settings > Personal access tokens > delete the token for that particular machine
I ran into this question while trying to switch from password authentication to PAT (personal access token).
I used https to work with Github. Github suggests (at the time of writing this answer) that the switch can be done by simplying entering my PAT instead of my password. However, the problem I had, was that my password was cached, so I never had to enter it.
I wrote this answer in more details and perhaps a little offtopic as starting in 2 days (August 13th 2021), password authentication will no longer be possible, and I suppose some users might have difficulty in locating their cached password.
If you're on windows 10, there is a credential manager in the OS to.
Go to Start menu, type "Credential Manager", then inside this manager, select "Windows Credentials", seek for "git:https//github.com", expand it, then you'll find "Delete" inside of it.
If you want to remove just one cached credential then that can be done in any operating system by driving the Git credential helper API from the Git command line:
Let's say the Git repository is git.example.com and you connect using HTTPS. At the operating system command prompt enter the Git command:
git credential reject
You're now on the command line for the credential API's reject function. Type the following lines:
protocol=https
host=git.example.com
On the next line, close the commands with the "end of stdin" keystroke for your operating system. Typically Ctrl-D for Linux and Macos, and maybe Ctrl-Z for Windows.
The credential has now been removed from the credential store. Since we are using Git's Credential API for the removal, it doesn't matter which credential store implementing that API is being used for the backend.
Do not alter Git's configuration of user.email or credential.helper before using the above command. Run the command as the userid you use to connect with the remote Git repository, not as a super-user.