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

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


当前回答

另一个有效的解决方法是:

1-进入控制面板,像这样添加github.com的凭据:

2-进入CMD并输入这些命令:

a- cd %localappdata%\Atlassian\SourceTree\git_local\mingw32\bin\ B - git.exe配置——编辑——系统 C -正确的最后一行: 助手=经理 d-保存新的配置文件,点击CTRL+C,然后输入:wq,然后按Enter

这对我来说太完美了!

其他回答

类似的错误是'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

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

git config --global credential.helper wincred

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

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

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

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

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

代码:读写 包装:阅读

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

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

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

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

git config --global credential.helper wincred

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