如何在 Windows 的 Git Bash 控制台中注销? [英] How do I sign out in the Git Bash console in Windows?

查看:20
本文介绍了如何在 Windows 的 Git Bash 控制台中注销?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 上使用 Git,版本 2.9.2.windows.1.

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

我在一个存储库项目上工作,当我进行推送时,它要求我输入我的 GitHub 用户名和密码.我输入了我的 GitHub 用户名和密码来更新项目.

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?

如何退出?

我试过了

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

但他们不会让我退出.

我想清除我的登录,所以下次我推送时,它会再次要求我输入我的用户名和密码.

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.

推荐答案

首先,用户认证与user.nameuser.email git config 无关.

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

其次,与旧答案从 git 中删除凭据"相比,最新的 Windows 版 Git 使用 Git 凭据管理器 (Git 2.9.2 => GCM 1.5.0).

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 -l)并查看是否manager"(或者,最近,2020+:manager-core")在那里注册.
如果没有,请使用:

Check your config (git config -l) and see if "manager" (or, more recently, 2020+: "manager-core") is registered there.
If not, set it up with:

 git config --global credential.helper manager-core

自 v1.3.0(2016 年 4 月)以来,它有一个 删除命令以清除凭据.

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

git credential-manager delete <url>

2018 年更新:删除"现在已弃用,请使用 reject:
2020 年更新:reject"现在已弃用,请使用 erase:

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

git credential-manager erase <url>

实际上,无论您使用什么 'xxx' 凭证管理器('xxx' 是 git config credential.helper 的结果),你可以这样做:

Actually, whatever 'xxx' credential manager you are using ('xxx' being the result of git config credential.helper), you can do:

printf "protocol=https
host=github.com" | git-credential-xxx erase

# Windows (2020-2021)
printf "protocol=https
host=github.com" | git-credential-manager-core erase

# Linux
printf "protocol=https
host=github.com" | git-credential-libsecret erase

# MacOs
printf "protocol=https
host=github.com" | git-credential-osxkeychain erase

这比摆弄操作系统的凭据管理器要好.

This is better than fiddling with the Credential Manager of your OS.

git-credential-xxx 可执行文件位于 usr/libexec/git-core 或(对于 Windows)mingw64/libexec/git-core.
正如 这里提到的,在 MacOS 上,它应该已经在 /usr/local/git/bin/.

That git-credential-xxx executable is in usr/libexec/git-core or (for Windows) mingw64/libexec/git-core of your Git installation.
As mentioned here, on MacOS, it should already be in /usr/local/git/bin/.

如果 git config credential-manager 返回 store,则 Git 使用store";模式,它将凭据保存到磁盘上的纯文本文件中,并且它们永不过期.

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.

OP Lord Rixuel实际上证实了在评论中它是一个本机 Windows 凭据管理器功能,自动提供(Git 与否)凭据:

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:

我看到了管理您的凭据"选项,出于好奇我点击它,然后我点击Windows Credentials",在Generic Credentials"下,有git:github.com",我点击它并且有删除"选项.我点击了删除.

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.

当我执行 git push 时,它会再次询问我的用户名和密码.当我想退出时,这正是我想要的.

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 Bash 控制台中注销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆