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

时间:2012-07-27 17:52:26

标签: 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

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

14 个答案:

答案 0 :(得分:307)

来自a blog I found

“此[git-credential-cache]不适用于Windows系统,因为git-credential-cache通过Unix套接字进行通信。”

Git for Windows

由于msysgit已被Git for Windows取代,因此使用Git for Windows是最简单的选择。某些版本的Git for Windows安装程序(例如2.7.4)在安装期间有一个复选框以启用Git Credential Manager。这是一个截图:

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或32位系统上的C:\ Program Files \ Git \ cmd。测试此方法的简便方法是启动命令提示符并键入git。如果你没有得到git命令列表,那么就没有正确设置。

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

git config --global credential.helper winstore

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

[credential]
    helper = winstore

完成此操作后,您可以通过Windows Credential Manager管理您的git凭据,您可以通过Windows控制面板进行管理。

答案 1 :(得分:55)

在{(msysgit)上看起来git现在随wincred开箱即用:

git config --global credential.helper wincred

<强>参考https://github.com/msysgit/git/commit/e2770979fec968a25ac21e34f9082bc17a71a780

答案 2 :(得分:21)

首先运行git config --global credential.helper wincred

然后转到:CONTROL PANEL\CREDENTIAL MANAGER\WINDOWS CREDENTIAL\GENERIC CREDENTIAL

然后点击添加凭据Internet or network address: 添加git:https:// {用户名} .github.com

User: {name}

Password: {密码}

答案 3 :(得分:19)

我在windows7上使用AptanaStudio3时遇到了这个问题。这对我有所帮助:

git config --global credential.helper wincred

代码来自here

答案 4 :(得分:10)

现在,通过在Windows上双击一个小的 exe ,可以更轻松地设置Git密码缓存。虽然该项目已从GitHub转移到http://gitcredentialstore.codeplex.com/

,但该程序仍然基于最高投票答案中提到的git-credential-winstore

您可以从以下博文中下载exe(以及Mac的二​​进制文件):https://github.com/blog/1104-credential-caching-for-wrist-friendly-git-usage

答案 5 :(得分:7)

首先找到您用于GIT的版本。

使用此命令:git --version

如果您的版本高于1.7.10。

然后只需使用此命令。

git config --global credential.helper wincred

Reference

答案 6 :(得分:6)

为了解决这个问题的其他人,我在Ubuntu中遇到了同样的问题(即我的密码没有缓存,尽管已正确设置选项,并且收到错误git: 'credential-cache' is not a git command.),直到我发现此功能仅适用于Git 1.7.9及更高版本

在Ubuntu的旧版本(Natty;我是一个顽固的Gnome 2用户)上,回购中的版本是git版本1.7.4.1。我使用以下PPA升级: https://launchpad.net/~git-core/+archive/ppa

答案 7 :(得分:5)

为了其他人有这个问题 - 我在这里登陆是因为我试图让我对如何设置一个新的github存储库变得可爱,但是根据setup page凭证助手不起作用,除非你克隆存储库。

&#34;提示:凭据帮助程序仅在克隆HTTPS存储库URL时有效。如果您使用SSH存储库URL,则使用SSH密钥进行身份验证。本指南提供了生成和使用SSH密钥对的帮助。&#34;

答案 8 :(得分:5)

类似的错误是'credential-wincred' is not a git command

现在接受和流行的答案已经过时了...

  

wincred用于项目git-credential-winstore,该项目为no longer maintained

     

Git-Credential-Manager-for-Windows维护的 Microsoft open source 代替。

从上面的链接中以zip文件下载发行版并将内容提取到

\cygwin\usr\libexec\git-core

(或者可能是\cygwin64\usr\libexec\git-core

然后启用它(通过设置全局.gitconfig)-执行:

git config --global credential.helper manager

使用方法

  

不需要进一步的配置。

     

当需要凭据时,它[自动]工作。

     

例如,当推送到Azure DevOps时,它将打开一个窗口并初始化oauth2流以获取令牌。

参考:

答案 9 :(得分:4)

我通过从特定项目的配置中删除credential部分来修复此问题:

  • 只需输入:git config -e
  • 在编辑器中,我删除了整个部分 [credential] helper = cache

这删除了恼人的消息:

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

答案 10 :(得分:3)

我知道我的谈话时间有些晚,但是我遇到了完全相同的问题 在我的git config中,我有两个条目凭据……

在我的.gitconfig文件中

[credential]
helper = cached
[credentials]
helper = wincred

修复:将我的.gitconfig文件更改为以下设置

[credential]
helper = wincred
[credentials]
helper = wincred

答案 11 :(得分:0)

我卸载了密码管理器,因此您必须为所有人输入密码

git credential-manager uninstall 

答案 12 :(得分:0)

域更改后,即从@ xy.com更改为@ xyz.com,我们的Azure DevOps存储库存在相同的问题。为解决此问题,我们生成了具有以下权限的全新个人访问令牌:

代码:读写 包装:阅读

然后,我们打开Windows凭据管理器,添加了具有以下详细信息的新的通用Windows凭据:

Internet或网络地址:“ git:{ projectname } @ dev.azure.com / { projectname }”-或者,您应该在此处使用您的git存储库名称。
用户名:“个人访问令牌”
密码: {生成的个人访问令牌}

此后,我们所有的git操作都再次起作用。希望这对其他人有帮助!

答案 13 :(得分:0)

在 mac 上运行以下命令:

git config --global credential.helper osxkeychain