WSL2上找不到Git凭证管理器

9

错误信息

/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe get: 1: /mnt/c/Program Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe: not found

问题描述

我在本地WSL2环境下与GitHub远程存储库进行git操作时,每次都需要输入用户名和密码进行身份验证,这非常烦人。

然后我搜索并按照互联网上找到的几个教程进行操作,但一切只会再次导致同样的问题,这些教程根本没有解决我的问题。

每个教程都告诉我应该在Windows环境中为WSL2环境中的git添加GCM目录,理论上这应该解决我的问题,但实际上并没有。

7个回答

23

解决方案

如果您的git文件夹中没有git-credential-core.exe,那么请使用它代替git-credential-wincred.exe。由于不存在-core可执行文件,因此我使用了-wincred文件。

在WSL2上执行此命令(如果存在-core,则使用其而不是-wincred):

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

仅当上述命令❌失败或未能解决问题时,更改为 -wincred

git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe"

说明

我认为git-credential-manager-core.exe已经更名为git-credential-wincred.exe,但因为很多教程给出的是旧的可执行文件名称,所以它们已经过时了。这是我最大的问题,因为按照任何教程进行操作都会导致我不断遇到同样的错误。


这对我没有起作用。使用“-wincred”会引发一些错误,但不幸的是我没有保存。它需要是“-core”,这个方法非常好(另一个答案)。 - Jan Vilimek
@JanVilimek 你应该先检查你的 Git 版本,在新版本中它使用 -wincred,而在旧版本中则使用 -core。 - ImBIOS
我正在使用2.37.0版本,错误可能是 <3>init: (30629) ERROR: UtilConnectToInteropServer:307: connect failed 2 ... 现在即使使用-core版本也会出现相同的错误 :/更新:该错误仅在vscode中发生...当从控制台(WSL/bash)运行时,它可以正常工作... - Jan Vilimek
@JanVilimek,您可以为此提出一个新问题,并请提供详细信息,例如vscode终端是否正在使用windows的gitcred。 - ImBIOS
谢谢!它对我有用,使用Linux和Windows感觉很痛苦:( - VinceNguyen
@VinceNguyen 是的,使用WSL2非常痛苦,根据我的经验,我建议我的朋友们使用本机Windows而不是使用WSL2,或者安装macOS或本机Linux。只要我们做事情,就不要半途而废,要全力以赴。 - ImBIOS

13

当我将Git for Windows升级到最近的版本(2.37.0)时,我在Windows 10上的WSL2遇到了类似的问题。这是因为git-credential-manager-core.exe已被移动到另一个文件夹中。

解决方案:

要解决此问题,请从bash命令行运行以下命令:

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

注意: 如果您在不同的驱动器/文件夹中安装了Git-请相应地更新路径。


太好了!那就是正确的路径。谢谢! - Jan Vilimek
3
git-credential-manager-core.exe 已更名为 git-credential-manager.exe(没有 -core)。 - Aaron Dake
git-credential-manager.exe在哪里?我没有那个exe文件,我只有git-credential-store和git-credential-wincred。 - undefined

1

我在使用安装在Windows和WSL上的Git版本2.34.1时遇到了同样的问题,结果发现他们已经移动了git-credential-manager-core.exe文件... 使用以下命令...

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

1

在WSL2上配置git似乎一直在不断发展,你需要筛选出许多过时的解决方案才能找到有效的方法,这真的很令人沮丧。每次我的token过期后,我都不能简单地用新的替换它。

确保你的Windows Git和WSL2中的Git版本相同。

对于我来说,使用GitHub个人访问令牌进行身份验证的问题得到了解决:

[credential]
helper = /mnt/c/Program\\ Files/Git/mingw64/bin/git-credential-manager.exe
credentialStore = wincred

注意:使用 git-credential-manager.exe,而不是过时的 git-credential-manager-core.exe。也不要用 32 位版本或者 git-credential-wincred.exe
另外注意:我看到一些回答中使用了 helper = ,但这对我没有用,我必须将其删除。

0

我曾经遇到过同样的问题,我的解决方法是找到文件:C:/Users/name.user/.gitconfig

然后用文本编辑器打开它,并进行了以下操作:

--DELETE

[credential]
    helper = wincred
    helper = 
    helper = C:/Program\\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe
-------

--Change correct repo
[credential "https://xyz.azure.com"]
------
Result:
[user]
    name = 'name.user'
    email = 'name.user@email.mx'
[credential https://myrepo.azure.com"]
    useHttpPath = true



0

我也遇到了类似的问题,使用WSL 2和全新安装的Git for Windows 2.38.1。

结果发现我从教程中得到的路径对我来说是错误的。在我的情况下,正确的命令是:

git config --global credential.helper "/mnt/c/Program\ Files\ \(x86\)/Git/mingw32/libexec/git-core/git-credential-wincred.exe"

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接