How do I sign out in the Git Bash console in Windows?

故事扮演 提交于 2019-11-26 03:34:27

问题


I\'m using Git, on Windows, version 2.9.2.windows.1.

I work on a repository project and when I do a push, it asked me to enter my GitHub username and password. I entered both my GitHub username and password to update the project.

In my next push, it doesn\'t ask for my username and password any more. All my modifications for the project are updated.

It looks like my username and password are \"saved\". How do I \"unsave\" them?

How do I sign out?

I tried

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

But they do not make me sign out.

I want to clear my sign in so the next time I make a push, it asks me again to enter my username and password.


I found my solution (Thanks to VonC):

Go to: Control PanelUser AccountsManage your credentialsWindows Credentials → under Generic Credentials there are some credentials related to GitHub. Click on them and click \"Remove\".

It signed me out so the next time I do a push, it asks me to enter my username and my password.


回答1:


First, user authentication has nothing to do with user.name and user.email git config.

And second, compared to the old answer "remove credentials from git", the latest Git for Windows uses Git Credential Manager (Git 2.9.2 => GCM 1.5.0).

 git config --global credential.helper manager 

Check your config (git config -l) and see if "manager" is registered there.

Since its v1.3.0 (April 2016), it has a delete command to purge credentials.

git credential-manager delete <url>

Update 2018: "delete" is now deprecated, use reject:

git credential-manager reject <url>

If git config credential-manager returns store, then Git uses the “store” mode, which saves the credentials to a plain-text file on disk, and they never expire.

type %USERPROFILE%\.git-credentials

I would remove that particular credential helper from the config, as it stores credentials in plain text.


The OP Lord Rixuel actually confirms in the comments it is a native Windows Credential Manager function which provides automatically (Git or not) the credentials:

I see the "Manage your credentials" option, I click on it out of curiosity, then I click on "Windows Credentials", under "Generic Credentials", there is "git:github.com";, I click on it and there is the "Remove" option. I clicked Remove.

When I do a git push, it asks again for my user and my password. Exactly what I want when I want to sign out.




回答2:


For Windows 10, if your PC has a different login (a MSFT account) and GitHub is on another login, if you go to control panel → user accounts and search for credential manager, you will see "Web Credentials" and "Windows credentials".

GitHub seems to be taking the default ID that is registered in the PC (Microsoft account). Under Windows Credentials, remove the GitHub login details and try Push again. You will be prompted for a GitHub ID and password explicitly. Once we login that gets stored as a personal access token for Git push.




回答3:


Reason for this Issue :

1.Previously logged in account credentials are saved in Windows Credentials.

2.Due to this, Gitbash gives error and doesn't allow us to login for new credentials

For SOLUTION Follow the steps:

Control Panel -> User Accounts -> Manage your credentials -> Windows Credentials -> under Generic Credentials there are some credentials related to Github, click on them and click "Remove".

This removes any prior logins without any issues. A fresh new login check is provided in Gitbash console which asks for your login credentials in order to save them.




回答4:


If you're using multiple accounts (which is what brought me here), it's more effective to unset the credential manager in the global Git configuration and use the prompt screen.

I was not able to find how to manage multiple accounts, through the credential manager documentation which are rather bare-bones at the moment.




回答5:


Also, don't forget to remove your SSH key if you have any. Even if you remove your credentials, if you have an SSH key you will still be able to log on automatically.




回答6:


Because you did login in another account, and that account doesn't have access rights to this repo, if you're using mac os, go to Keychain Access, search for gitlab.com, remove it and try to git clone again.




回答7:


If you want to change the account, as as later:

git config --global user.name "new name"
git config --global user.email "new email"
git config --list
git help
git help commit


来源:https://stackoverflow.com/questions/38549834/how-do-i-sign-out-in-the-git-bash-console-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!