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

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


当前回答

在.gitconfig的[credential]部分中有三个不同的helper=条目,其中一个是空的。删除另外两个并保留helper=wincred为我解决了这个问题。

BTW:我不知道为什么,但我没有立即找到我的.gitconfig。然后我在c:\ users \username中找到了它

其他回答

在旧的Ubuntu Linux系统上:

git config --global credential.helper store

看起来git现在带有wincred开箱即用的Windows (msysgit):

git config --global credential.helper wincred

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

这招对我很管用:

git credential-manager-core configure

在.gitconfig的[credential]部分中有三个不同的helper=条目,其中一个是空的。删除另外两个并保留helper=wincred为我解决了这个问题。

BTW:我不知道为什么,但我没有立即找到我的.gitconfig。然后我在c:\ users \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