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

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


当前回答

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

代码:读写 包装:阅读

然后我们打开Windows凭据管理器,添加一个新的通用Windows凭据,详细信息如下:

Internet或网络地址:"git:{projectname}@dev.azure.com/{projectname}" -或者你可以在这里使用你的git存储库名称。 用户名:“个人访问令牌” 密码:{生成的个人访问令牌}

后来我们所有的git操作都恢复正常了。希望这能帮助到其他人!

其他回答

为了让其他人知道这个问题,我在Ubuntu中也遇到了同样的问题(即我的密码没有缓存,尽管已经正确地设置了选项,并且得到了错误git: '凭据-缓存'不是git命令),直到我发现这个功能只在git 1.7.9及以上版本中可用。

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

对于git版本>=1.7.10(使用git——version检查),使用以下方法(参考):

窗口:

git config --global credential.helper wincred

Mac:

git config --global credential.helper osxkeychain

我刚刚真的经历了这个!

下载Git Credential Manager Core并安装:https://github.com/microsoft/Git-Credential-Manager-Core#download-and-install 进入GitHub上的帐户设置>电子邮件。你应该会看到这样的东西: 突出显示的电子邮件是系统生成的,以保持您的私人电子邮件私密性。现在复制它,并在下一步中使用它 配置git:

 git config --global user.name "yourusername"
 git config --global user.email "1234567+yourgithubusername@users.noreply.github.com"
 git config --global credential.helper cache

现在,git命令应该可以再次工作了。

小提示:我使用的是Linux Mint。YMMV

附加说明:在Debian版本的Git凭证管理器核心v 2.0.567中有一个bug。请在新版本发布之前安装v2.0.474。

我也得到类似的错误,当我试图使用命令“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现在带有wincred开箱即用的Windows (msysgit):

git config --global credential.helper wincred

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