Git 从命令行注销用户



有没有注销 git 的命令?我正在将我的计算机交给其他人,并且不希望 git 附加到我在终端中的帐户。

我遇到了同样的问题,上面的答案对我不起作用,因为 github 是通过 Windows 凭据管理器而不是 git bash 输入我的凭据的。

您可能需要检查 Windows 凭据管理器并删除 control panel > user accounts > credential manager > Windows credentials > Generic credentials 下的 github 条目

~/.ssh(或存储它们的位置)中删除 SSH 密钥。

删除您的用户设置:

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

或所有全局设置:

git config --global --unset-all

也许还有其他与凭据存储相关的东西,但我总是使用 git 而不是 SSH。

在 Mac 上,凭据储存在"钥匙串访问"中。查找 Github 并删除该凭据。更多信息: https://help.github.com/articles/updating-credentials-from-the-osx-keychain/

在Windows上试试这个:

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

如果您在推送过程中遇到任何问题(在 Windows 操作系统中),只需按照以下步骤删除缓存的 git 帐户:

  1. 搜索控制面板并打开它。
  2. 搜索"凭据管理器"并打开它。
  3. 单击"管理您的凭据"页面下的"Windows 凭据"。
  4. 在"通用凭据"下,单击"GitHub"。
  5. 单击删除,然后单击"是"按钮进行确认。
  6. 现在
  7. 开始推送代码,您将获得GitHub弹出窗口以再次登录,现在您已完成。成功登录后,一切都将正常工作。

我在公司环境中,在最近更改密码后尝试进行简单的git pull

我得到:remote: Invalid username or password.

有趣的是,以下内容不起作用:git config --global --unset credential.helper

使用Windows-7,所以,我去了控制面板->凭据管理器->通用凭据。

从凭据管理器列表中,删除与 git 对应的行项。

删除后,返回 gitbash 和 git pull 应该会提示您输入凭据的对话框。

由于

使用其他凭据登录,我无法克隆存储库。

要切换到另一个用户,我做了:

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

然后我克隆的不是 ssh 网址,而是 https 网址。它要求提供凭据,它奏效了。

就我而言,这些解决方案都不起作用(不是手动清理~/.gitconfig),所以我不得不重命名本地存储库文件夹(以避免丢失本地更改)并再次git clone远程存储库...

最新更新