我严格遵守了这些说明,包括关于密码缓存的部分。看起来指令是错误的,因为每次我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版本>=1.7.10(使用git——version检查),使用以下方法(参考):

窗口:

git config --global credential.helper wincred

Mac:

git config --global credential.helper osxkeychain

其他回答

类似的错误是'credential-wincred'不是git命令

那些公认的、流行的答案现在已经过时了。

Wincred用于git-credential-winstore项目,该项目已不再维护。 它被微软开源维护的Git-Credential-Manager-for-Windows所取代。

从上面的链接下载zip文件,并提取内容到

\cygwin\usr\libexec\git-core

(或\cygwin64\usr\libexec\git-core)

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

git config --global credential.helper manager

如何使用

不需要进一步配置。 当需要凭据时,它[自动]工作。 例如,当推送到Azure DevOps时,它会打开一个窗口并初始化oauth2流以获取您的令牌。

ref:

https://github.com/babun/babun/issues/318 https://github.com/Microsoft/Git-Credential-Manager-for-Windows#installation-in-an-msys2-environment

为了其他人有这个问题-我降落在这里,因为我试图得到可爱的我如何设置一个新的github存储库,但每个设置页面凭据帮助不工作,除非你克隆一个存储库。

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

我通过从特定项目的配置中删除凭据部分来修复这个问题:

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

这就消除了恼人的信息:

'credential-cache'不是Git命令。参见'git -help'。

执行git config——global credential命令。辅助wincred 转到:控制面板\证书管理器\WINDOWS证书\通用证书 在Internet或网络地址中单击“添加证书”:add git: https:// .github.com {username} 用户:{名称} 密码密码:{}

现在有一种更简单的方法来设置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