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

标签 git msysgit git-bash git-config

我关注了these instructions逐字逐句,包括有关密码缓存的部分。似乎说明是错误的,因为每次我 git push origin master 我都会收到这个错误:

git: 'credential-cache' is not a git command. See 'get --help'.

...此时我被迫输入我的用户名和密码。这样做之后,我再次看到相同的错误消息,然后是 git push 的输出。

这是我的 .gitconfig 文件的内容:

[user]
    name = myusername
    email = myusername@myemaildomain.com
[credential]
    helper = cache

需要说明的是,在我安装 Git 并运行 Git Bash 之后,这正是我输入的内容:

git config --global user.name "myusername"
git config --global user.email "myusername@myemaildomain.com"
git config --global credential.helper cache

请帮忙。这太令人沮丧了!

最佳答案

来自 a blog I found :

This [git-credential-cache] doesn’t work for Windows systems as git-credential-cache communicates through a Unix socket.

Windows 版 Git

由于 msysgit 已被 Git for Windows 取代,使用 Git for Windows现在是最简单的选择。 Windows 安装程序的某些版本的 Git(例如 2.7.4)在安装过程中有一个复选框以启用 Git 凭据管理器。这是一个屏幕截图:

screenshot of Git For Windows 2.7.4 install wizard

还在使用 msysgit 吗?适用于 msysgit 1.8.1 及以上版本

msysgit 1.8.1 添加了 wincred 助手。按如下方式使用它:

git config --global credential.helper wincred

对于早于 1.8.1 的 msysgit 版本

首先,下载git-credential-winstore并将其安装在您的 git bin 目录中。

接下来,确保包含 git.cmd 的目录在您的 Path 环境变量中。默认目录在 64 位系统上是 C:\Program Files (x86)\Git\cmd 或在 C:\Program Files\Git\cmd 32位系统。一个简单的测试方法是启动命令提示符并键入 git。如果您没有获得 git 命令列表,则说明它没有正确设置。

最后,启动命令提示符并键入:

git config --global credential.helper winstore

或者您可以手动编辑您的 .gitconfig 文件:

[credential]
    helper = winstore

完成此操作后,您可以通过 Windows 凭据管理器管理您的 git 凭据,您可以通过 Windows 控制面板将其调出。

关于git: 'credential-cache' 不是 git 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11693074/

相关文章:

git - 仅显示不影响任何指定路径的提交

git - msysgit 的麻烦

git - Cygwin:git 的颜色编码和分支信息?

git - 我必须为每台计算机生成 SSH key ,还是复制 `~/.ssh` 目录的内容就足够了?

bitbucket - 如果我克隆 TortoiseGit 身份验证失败

Github Desktop - 不显示更改

git - 忽略同一根目录中的多个文件夹

git - 即使在添加 ssh key 后也无法克隆任何 git repo

linux - 如何将 git repo 上传到 gerrit?

windows - git EOL 以相反的方式转换? (尽管 .gitattributes)