如何在 Windows 中的 Git Bash 控制台中注销?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38549834/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I sign out in the Git Bash console in Windows?
提问by Lord Rixuel
I'm using Git, on Windows, version 2.9.2.windows.1.
我在 Windows 上使用 Git,版本为 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.
我在一个存储库项目上工作,当我进行推送时,它要求我输入我的 GitHub 用户名和密码。我输入了我的 GitHub 用户名和密码来更新项目。
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):
我找到了我的解决方案(感谢 VonC):
Go to: Control Panel→ User Accounts→ Manage your credentials→ Windows Credentials→ under Generic Credentialsthere are some credentials related to GitHub. Click on them and click "Remove".
转到:控制面板→用户帐户→管理您的凭证→ Windows 凭证→ 在通用凭证下有一些与 GitHub 相关的凭证。单击它们,然后单击“删除”。
It signed me out so the next time I do a push, it asks me to enter my username and my password.
它让我退出,所以下次我推送时,它会要求我输入我的用户名和密码。
采纳答案by VonC
First, user authentication has nothing to do with user.name
and user.email
git config.
首先,用户认证user.name
和user.email
git config无关。
And second, compared to the old answer "remove credentials from git", the latest Git for Windowsuses Git Credential Manager(Git 2.9.2 => GCM 1.5.0).
其次,与旧答案“从 git 中删除凭据”相比,最新的 Windows 版Git使用Git 凭据管理器(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.
检查您的配置 ( git config -l
) 并查看“经理”是否在那里注册。
Since its v1.3.0 (April 2016), it has a delete command to purge credentials.
自 v1.3.0(2016 年 4 月)以来,它有一个删除命令来清除凭据。
git credential-manager delete <url>
Update 2018: "delete
" is now deprecated, use reject
:
2018 年更新:“ delete
” 现在已弃用,请使用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.
如果 git config credential-manager 返回 store,则 Git 使用“store”模式,将凭据保存到磁盘上的纯文本文件中,并且它们永不过期。
type %USERPROFILE%\.git-credentials
I would remove that particular credential helper from the config, as it stores credentials in plain text.
我会从配置中删除那个特定的凭证助手,因为它以纯文本形式存储凭证。
The OP Lord Rixuelactually confirms in the commentsit is a native Windows Credential Manager function which provides automatically (Git or not) the credentials:
该OP主Rixuel实际上确认在评论这是一个地道的Windows凭据管理器功能,可以自动提供(GIT与否)的凭据:
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.
我看到“管理您的凭据”选项,出于好奇,我单击了它,然后单击“Windows 凭据”,在“通用凭据”下,有“
git:github.com
”;我单击它,然后有“删除”选项。我点击了删除。当我执行 git push 时,它会再次询问我的用户和密码。当我想退出时,这正是我想要的。
回答by karthick krishnan
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".
对于 Windows 10,如果您的 PC 使用不同的登录名(MSFT 帐户)并且 GitHub 使用另一个登录名,如果您转到控制面板 → 用户帐户并搜索凭据管理器,您将看到“Web 凭据”和“Windows 凭据” .
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 Pushagain. 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.
GitHub 似乎采用了在 PC(Microsoft 帐户)中注册的默认 ID。在Windows Credentials 下,删除 GitHub 登录详细信息并再次尝试推送。系统将明确提示您输入 GitHub ID 和密码。一旦我们登录,它就会存储为 Git 推送的个人访问令牌。
回答by Aniket Patil
Reason for this Issue :
此问题的原因:
1.Previously logged in account credentials are saved in Windows Credentials.
1.以前登录的帐户凭据保存在 Windows Credentials 中。
2.Due to this, Gitbash gives error and doesn't allow us to login for new credentials
2.因此,Gitbash给出错误并且不允许我们登录以获取新凭据
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".
控制面板 -> 用户帐户 -> 管理您的凭据 -> Windows 凭据 -> 在通用凭据下有一些与 Github 相关的凭据,单击它们并单击“删除”。
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.
这将删除任何先前的登录,而不会出现任何问题。Gitbash 控制台中提供了一个全新的登录检查,要求您提供登录凭据以保存它们。
回答by Anne de Graaf
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.
另外,如果您有 SSH 密钥,请不要忘记删除。即使您删除了凭据,如果您拥有 SSH 密钥,您仍然可以自动登录。
回答by Hieu Vo
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.
因为您确实登录了另一个帐户,而该帐户没有访问此 repo 的权限,如果您使用的是 mac os,请转到Keychain Access,搜索gitlab.com
,将其删除并再次尝试 git clone。
回答by Anuran
The only option worked for me to remove storing of Git credentials is the following command.
git credential-manager remove
对我来说删除 Git 凭据存储的唯一选项是以下命令。
git credential-manager remove
回答by NickersF
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.
如果您使用多个帐户(这就是我来到这里的原因),在全局 Git 配置中取消设置凭证管理器并使用提示屏幕会更有效。
I was not able to find how to manage multiple accounts, through the credential manager documentation which are rather bare-bones at the moment.
通过目前相当简单的凭证管理器文档,我无法找到如何管理多个帐户。
回答by HAO PHAN XUAN
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