简体   繁体   English

在 WSL2 上找不到 Git 凭据管理器

[英]Git Credential Manager Not Found on WSL2

Error Message错误信息

/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

Problem Story问题故事

I found this problem then git ask me for a username and password to authenticate to GitHub whenever I'm doing git activity with GitHub remote repository from my local WSL2 environment.我发现了这个问题,然后每当我在本地 WSL2 环境中使用 GitHub 远程存储库执行 git 活动时,git 都会要求我提供用户名和密码以向 GitHub 进行身份验证。

It is very annoying to do this every time, then I search and follow several tutorials I can find on the internet, but everything just led me to the same problem again, these tutorial is not solving my problem at all.每次都这样做很烦人,然后我搜索并按照我可以在互联网上找到的几个教程进行操作,但一切都让我再次遇到同样的问题,这些教程根本没有解决我的问题。

Every tutorial tells me that I should add the GCM directory in the Windows environment for the git in the WSL2 environment.每个教程都告诉我,我应该为WSL2环境中的git添加Windows环境中的GCM目录。 Theoretically, it should solve my problem, but it is not.从理论上讲,它应该可以解决我的问题,但事实并非如此。

Solution解决方案

Execute this command on WSL2:在 WSL2 上执行此命令:

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

Explanation解释

I think git-credential-manager-core.exe has already been renamed to git-credential-wincred.exe but many tutorials on the internet are already deprecated because they gave us the old name of this executable file.我认为git-credential-manager-core.exe已经重命名为git-credential-wincred.exe但互联网上的许多教程已经被弃用,因为它们给了我们这个可执行文件的旧名称。 This is my biggest problem because following any tutorial just makes me find the same error over time.这是我最大的问题,因为遵循任何教程只会让我随着时间的推移发现同样的错误。

I faced a similar issue on WSL2 with Windows 10 when I upgraded Git for Windows to one of the recent versions (2.37.0 I think).当我将适用于 Windows 的 Git 升级到最新版本之一(我认为是 2.37.0)时,我在 Windows 10 的 WSL2 上遇到了类似的问题。 This is because the git-credential-manager-core.exe has been moved to a different folder.这是因为 git-credential-manager-core.exe 已移动到不同的文件夹。

Solution:解决方案:

To fix this issue, run the following command from your bash command line:要解决此问题,请从 bash 命令行运行以下命令:

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

Note: If you have Git installed in a different drive/folder - update the path accordingly.注意:如果您将 Git 安装在不同的驱动器/文件夹中 - 相应地更新路径。

I had the same problem, what I did was identify the file: C:/Users/name.user/.gitconfig我有同样的问题,我所做的是识别文件:C:/Users/name.user/.gitconfig

I open it with a text edit and did the following我用文本编辑打开它并做了以下

--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


I experienced similar issues as well, with WSL 2 and fresh install of Git for Windows 2.38.1.我也遇到过类似的问题,WSL 2 和 Git for Windows 2.38.1 的全新安装。

Turned out the path I got from the tutorials was wrong for me.原来我从教程中得到的路径对我来说是错误的。 In my case the correct command was:在我的例子中,正确的命令是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM