首页 > 解决方案 > 安装 libsecret 凭据帮助程序后出现 git push 错误:“credential--h”不是 git 命令

问题描述

我按照此处的说明安装了 libsecret 凭据帮助程序:https ://www.softwaredeveloper.blog/git-credential-storage-libsecret

现在,当我推送时git: 'credential --h' is not a git command. See 'git --help',即使推送成功,我也会收到错误消息。为什么?

输出git config -l --show-origin | grep credential

file:/home/alex/.gitconfig  credential.helper=/usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
file:.git/config    credential.helper=-h

标签: gitcredentials

解决方案


问题是您输入了不正确的.git/config. 这很可能只是一个错字,这实际上并不少见。当您将凭证帮助程序指定为单个单词时,Git 会git credential-在它前面添加,从而产生您看到的消息。

要修复它,只需.git/config使用您喜欢的编辑器编辑文件并删除不正确的条目。

它继续工作的原因是因为 Git 使用每个凭证助手来查询然后批准或拒绝凭证。结果,您的功能性 libsecret 凭证助手仍然被调用,它提供了您需要的凭证,而损坏的条目仅被调用以批准这些凭证,从而导致您看到的错误。


推荐阅读