好像没法让Git凭据管理器正常工作

编程语言 2026-07-09

我知道这个问题此前已经被提及过,形式各不相同,但我仍然无法让它按我在此处和网上其他地方找到的答案工作。当我运行时

git credential-manager --version

我得到这个错误:

git: 'credential-manager' 不是一个git命令。请参阅 'git --help'

我已经使用

git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"

命令来设置 git-credential-manager 的位置,看起来似乎成功。我可以获取这个设置:

git config --global credential.helper
/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe

据我所知,路径是正确的。我可以直接运行该可执行文件:

/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe --version
2.7.3+5fa7116896c82164996a609accd1c5ad90fe730a

Windows版 Git、WSL和 Ubuntu发行版的Git安装都是今天完成的,所以我对自己正在使用的都是最新版的相当有信心。

最近有变化吗?我是不是漏掉了什么明显的地方?

先行感谢你的帮助。

解决方案

Subcommand lookup for git <subcommand> does not care about the specific helper settings. It uses a generic procedure no matter what subcommand it is, no matter if it happens to start with "credential-" or not. That is, if the subcommand is not built-in (and not found in git's internal bin directory), then git looks for it only in your %PATH% – almost exactly as if you were to directly run git-<subcommand>.exe from the shell.

(通常来说,"credential.helper" 是一个处于较高层次的设置,底层的子命令查找等机制不能依赖它。)

If you want the helper to be runnable as a git subcommand, then you need to add its directory to your $PATH or %PATH% environment variable.

Either way, it is not necessary to be able to run the helper as a git subcommand. If you had configured only a plain subcommand for credential.helper then it would of course need to be runnable as a subcommand, but as you specified a full path to the .exe instead, it's enough for it to be accessible by that full path (which as you've demonstrated already works).

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章