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.
-
6What operating system are you on? How about just wiping your hard disk? – Sven Marnach Jan 30 '15 at 14:42
-
1I'm on OS X. I'd like to hand over my computer without wiping everything. I just don't want personal information, repositories accessible. – byrdr Jan 30 '15 at 14:45
-
2Is wiping your home directory an option? It typically contains a whole lot of personal information, which will be hard to get rid of completely. – Sven Marnach Jan 30 '15 at 14:54
-
10_o `git` doesn't really have a conception of "logged in" or "logged out". If you didn't log in to something, you generally can't log out of it, either. – Jan 30 '15 at 15:19
-
@bydr Configure fast user switching and switch to guest user before handing your laptop over. – kwerle Jan 18 '17 at 17:08
-
3You could also just change your password on github/bitbucket/whatever website you use. – Afas May 24 '18 at 21:42
-
I tried everything to try to log out of git then my colleague pointed out I'd signed in using an app password, so I'd need to revoke that app password to stop access to GIT on that server. Once I did this, 'git pull' stopped working, which is what I wanted :) – Gail Foad Jan 23 '23 at 14:59
8 Answers
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
-
2This solution fixed my issues on Windows 10 with error 403 while I am trying to use HTTPS protocol and two different usernames. I think the problem stems from the Git Desktop Client. I don't use it at home, and I have no issues there. Here at the office, I couldn't push to my personal repo. Blowing out the Windows credentials via the above steps seems to have done the trick. It also caused the Git login window to load when I did `git push`, so that's why I suspect the Desktop Client. – agm1984 May 02 '17 at 17:55
-
10`git config --global --unset credential.helper` works great. I couldn't find the login in credential manager as mentioned. – Ravimallya Oct 11 '17 at 04:37
-
2To access Windows credentials see https://support.microsoft.com/en-us/help/4026814/windows-accessing-credential-manager. – CoolMind Dec 12 '17 at 16:37
-
12
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.

- 11,364
- 15
- 100
- 180

- 14,493
- 4
- 32
- 41
-
1This really depends on the OS, and on the credential store used. In general, it will be difficult to completely make sure you don't leak any secrets. – Sven Marnach Jan 30 '15 at 14:44
-
2This did not work for me. If you are in a corporate environment, privileges vary. I had to manually remove a stale credential from the Windows Vault. See my response below. – Rao Pathangi Sep 09 '18 at 14:41
-
80For me `git config --global --unset-all` outputs `error: wrong number of arguments, should be from 1 to 2` ? – Senju Sep 07 '19 at 10:08
-
11`git config --global --unset credential.helper` Do this as the above comment is not working – devDeejay Jul 05 '20 at 03:50
-
1The commands above depend on the version of git. I've recently update my version of git, and I have to use devDeejay answer. – cnxsoft Aug 14 '21 at 04:28
-
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/

- 451
- 4
- 2
Try this on Windows:
cmdkey /delete:LegacyGeneric:target=git:https://github.com

- 684
- 1
- 8
- 16
If you are facing any issues during push ( in windows OS), just remove the cached git account by following the given steps below:
- Search for Control panel and open the same.
- Search for Credential Manager and open this.
- Click on Windows Credentials under Manage your credentials page.
- Under Generic Credentials click on GitHub.
- Click on Remove and then confirm by clicking Yes button.
- 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.

- 2,921
- 1
- 29
- 31

- 181
- 1
- 4
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.

- 504
- 3
- 11
-
+1 Exactly what i was looking for. Except it was in Windows Credentials instead of Generic Credentials for my windows 8. – DTdev Jan 01 '19 at 14:01
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.

- 2,934
- 2
- 35
- 56

- 190
- 1
- 6
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...

- 4,799
- 3
- 38
- 59