git: 'credential-manager' 不是 git 命令

21

我有一台运行Ubuntu 18.04.3 LTS的服务器。我希望保存我的git凭证,这样我就不必每次都输入它们。我运行以下命令:

git config --global credential.helper store

然后我执行 git pull 命令,得到如下输出:

user@host:~/project$ git pull
git: 'credential-manager' is not a git command. See 'git --help'.
usage: git credential-store [<options>] <action>

    --file <path>         fetch and store credentials in <path>

Username for 'https://gitlab.com':

然后我被要求输入用户名和密码。之后同样的错误信息被打印出来。

我已经重复了几次相同的过程,使用以下命令取消设置credential.helper选项:

git config --global --unset credential.helper

1
在该存储库的文件夹中,git config credential.helper 会输出什么? - Lasse V. Karlsen
git config credential.helper outputs store - goedwig
1
git config --get-all credential.helper 将显示你设置了两个 helper。Git 按顺序尝试它们。第一个失败因为“未找到”,第二个因为缺少参数而失败。使用 git config --show-origin 查找这两个命令的定义位置。 - torek
2
来自@torek的信息组合:git config --show-origin --get-all credential.helper - HolyGuacamole
4个回答

34

我执行了这个命令

git config --global --unset credential.helper

此时我在使用git pull命令后没有出现任何错误。我的git版本是2.34.1.windows.1。


这应该被设置为最佳答案。我尝试了许多其他解决方案,但它们都没有起作用。 - Louis
这个。这绝对是最好的答案。谢谢。 - natedog0925

7

这份文档展示了该命令。

$ git config --global credential.helper 'store --file ~/.my-credentials'

因此,git 很可能只是执行在 credential.helper 中设置的命令。你设置的命令只是 store ... 它需要一个强制参数 ... 但是你没有提供。

这解释了为什么 store 命令(实际上是 git credential-store)不能按照你的期望工作。

我不知道有关 credential-manager 的投诉从何而来——很可能它只是将所有故障状态误报为“不是 git 命令”。


1
可能是因为你正在使用的凭证管理器命令已经过时或适用于不同的操作系统。 在遵循关于保存GitHub凭据的博客后,我遇到了这个问题,然后意识到它们是针对Windows而不是Linux的。 也有可能是我没有像Useless在他/她的答案中所述那样传递适当的参数。 无论哪种方式,我通过进入~/.gitconfig并删除关于凭证管理器的末尾行来解决了这个问题。 但请自行承担风险。 我不知道是否会有未预见的后果。

0

这个答案帮助我解决了以下命令的问题:

git config --remove-section credential

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接