Git 从命令行注销用户

Git log out user from command line

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

~/.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

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

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

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

下的 git 集线器条目

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

我在公司环境中,在最近更改密码后尝试简单 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 URL,而是使用 https url 进行了克隆。 它要求提供凭据并且有效。

在 Windows 上试试这个:

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

如果您在推送过程中遇到任何问题(在 windows OS 中),只需按照以下给定步骤删除缓存的 git 帐户:

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

在我的例子中,这些解决方案中的 none 有效(不是手动清理 ~/.gitconfig),所以我不得不重命名本地 repo 文件夹(以避免丢失本地更改)和 git clone 再次远程回购...