Git log out user from command line

Git

Git Problem Overview


Is there a command for logging out of git? I'm turning my computer over to somebody else and don't want the git to be attached to my account in the terminal.

Git Solutions


Solution 1 - Git

I came across this same problem, and the above answer didn't work for me because github was being fed my credentials through windows credential manager instead of git bash.

You may have to check windows credential manager and delete the github entry under control panel > user accounts > credential manager > Windows credentials > Generic credentials

Solution 2 - Git

Remove your SSH keys from ~/.ssh (or where you stored them).

Remove your user settings:

git config --global --unset user.name
git config --global --unset user.email
git config --global --unset credential.helper

Or all your global settings:

git config --global --unset-all

Maybe there's something else related to the credentials store, but I always used git over SSH.

Solution 3 - Git

On a Mac, credentials are stored in Keychain Access. Look for Github and remove that credential. More info: https://help.github.com/articles/updating-credentials-from-the-osx-keychain/

Solution 4 - Git

I am in a corporate setting and was attempting a simple git pull after a recent change in password.

I got: remote: Invalid username or password.

Interestingly, the following did not work: git config --global --unset credential.helper

I use Windows-7, so, I went to control panel -> Credential Manager -> Generic Credentials.

From the credential manager list, delete the line items corresponding to git.

After the deletion, come back to gitbash and git pull should prompt the dialog for you to enter your credentials.

Solution 5 - Git

Try this on Windows:

cmdkey /delete:LegacyGeneric:target=git:https://github.com

Solution 6 - Git

I could not clone a repository due to being logged on with other credentials.

To switch to another user, I did:

git config --global --unset user.name
git config --global --unset user.email
git config --global --unset credential.helper

Then I cloned not with the ssh URL, but with the https url. It asked for credentials and it worked.

Solution 7 - Git

If you are facing any issues during push ( in windows OS), just remove the cached git account by following the given steps below:

  1. Search for Control panel and open the same.
  2. Search for Credential Manager and open this.
  3. Click on Windows Credentials under Manage your credentials page.
  4. Under Generic Credentials click on GitHub.
  5. Click on Remove and then confirm by clicking Yes button.
  6. Now start pushing the code and you will get GitHub popup to login again and now you are done. Everything will work properly after successful login.

Solution 8 - Git

In my case none of these solutions worked (not evel manual cleaning of ~/.gitconfig), so I had to rename the local repo folder (to avoid losing local changes) and git clone the remote repo again...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionbyrdrView Question on Stackoverflow
Solution 1 - Gitman guyView Answer on Stackoverflow
Solution 2 - GitAlessandro VendruscoloView Answer on Stackoverflow
Solution 3 - GitSeth DView Answer on Stackoverflow
Solution 4 - GitRao PathangiView Answer on Stackoverflow
Solution 5 - GitUser52016View Answer on Stackoverflow
Solution 6 - GitDiego SayronView Answer on Stackoverflow
Solution 7 - GitShubham BhardwajView Answer on Stackoverflow
Solution 8 - GitmirekphdView Answer on Stackoverflow