我严格遵守了这些说明,包括关于密码缓存的部分。看起来指令是错误的,因为每次我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

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


当前回答

在我的案例中,这个命令解决了这个问题:

git config --global credential.helper manager-core --replace-all

使用新的网络核心凭据管理器。

其他回答

我也得到类似的错误,当我试图使用命令“git拉”从主分支。

Error: "git: 'credential-manager' is not a git command. See 'git --help'." 

我执行下面两个命令,问题得到解决。

$ git config --global --unset credential.helper
$ git config credential.helper store

现在有一种更简单的方法来设置Git密码缓存,只需双击Windows上的一个小exe即可。该程序仍然基于投票最多的答案所提到的git-credential-winstore,尽管该项目已经从GitHub移动到http://gitcredentialstore.codeplex.com/

你可以从这篇博客上下载exe(和Mac的二进制文件):https://github.com/blog/1104-credential-caching-for-wrist-friendly-git-usage

在我的案例中,这个命令解决了这个问题:

git config --global credential.helper manager-core --replace-all

使用新的网络核心凭据管理器。

在旧的Ubuntu Linux系统上:

git config --global credential.helper store

我在一个博客上发现:

这个[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凭据管理器。以下是截图:

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

在msysgit 1.8.1中添加了wincred helper。使用方法如下:

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凭据管理器来管理你的git凭据,你可以通过Windows控制面板拉出凭据管理器。