简体   繁体   中英

Using WSL git with Windows integration

I cannot get git-credential-manager.exe to operate with WSL (latest Ubuntu distro). I see various questions on Stackoverflow about this but none answer this for me.

My situation is simple. Everything is up to date. git is installed in WSL. git is already the newest version (1:2.25.1-1ubuntu3.1). Git for Windows is installed in Windows (Git for Windows v2.31.1, "Latest update: March 27th 2021"). Even worse: I have completely reinstalled Windows and then setup WSL and put a new Ubuntu instance onto it, and Windows integration with git still completely fails, so if I'm doing something wrong, I'd really appreciate knowing what that is!

Now, in WSL, I have setup the git-credential-manager to use Git for Windows. sudo vi /usr/bin/git-credential-manager , then add:

#!/bin/sh
exec "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe" $@

Save the file, then sudo chmod +x /usr/bin/git-credential-manager ok, so everything is (supposedly) setup. Inside my git project, I type git push -u origin master .

The Git for Windows credential manager pops open asking me for my credentials, so I input them. Then it all fails:

Logon failed, use ctrl+c to cancel basic credential prompt.
Username for 'https://github.com':

I can manually input my username and password on the command line, and this DOES work, BUT a) I have to do this every time , and b) Github will kill this option in a few months time.

In summary:

  • From Windows, I can push my PowerShell projects without issues, Git for Windows handles my authorization (so I don't need to input username/password every time I do a push).
  • From WSL Ubuntu, when I push my bash/python projects, Git for Windows credential manager pops open (every time) to ask for my username/password, but then completely fails to authorise ( Logon failed, use ctrl+c to cancel basic credential prompt ) and I have to manually input username/password to git in bash (every time).

Any advice on this would be really appreciated, as it's frustrating to not have the seamless WSL operation that I've read should be possible, and even worse, all of this will break in a few months when Github prevent sending credentials from the console.

Apart from /usr/bin/git-credential-manager change, you need to run:

cat << EOF >> ~/.gitconfig
[credential]
    helper = manager
EOF

It should work now. If not, try to use /mnt/c/Program Files/Git/bin/git.exe instead of /usr/bin/git

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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