为何`git config --global credential.helper`显示wincred,实际却在用Git Credential Manager Core?
GCM Core 会自动接管旧凭据助手的配置
当你安装 Git Credential Manager Core(GCM Core)后,它会在 Git 的系统级配置中添加自己的凭据助手设置,而系统级配置的优先级高于你查看的全局配置(git config --global)。即便全局配置显示为wincred,Git 实际会优先使用系统级配置里的 GCM Core 来处理凭据。直接调用 GCM Core 命令不受当前 helper 配置影响
你执行的printf "host=github.com\nprotocol=https\nusername=ooker777\npassword=ghp_yourToken" | git credential-manager-core store是直接调用 GCM Core 的存储命令,这个操作绕开了当前配置的credential.helper项,直接将令牌存入 GCM Core 专属的加密存储(比如 Windows 上的 Credential Locker,和旧的 Windows Credentials 不是同一位置),所以能正常推送代码。旧的 Windows Credentials 是遗留数据
你看到的 Windows Credentials 里的 GitHub 密码是之前使用旧凭据助手时留下的,现在 GCM Core 不会再使用这个数据,所以它失效也不影响当前的推送操作。
如果想确认实际生效的凭据助手,可以执行以下命令查看所有层级的配置:
git config --show-origin --get credential.helper
这个命令会列出系统、全局、局部仓库所有的 credential.helper 设置,你会发现系统级配置里有 GCM Core 的条目,它的优先级最高。
内容的提问来源于stack exchange,提问作者Ooker

