1

I'm on a machine running Windows 10, with Developer Mode enabled and the Linux Subsystem installed. When I switch into bash, I am trying to run a simple clone command from git:

git clone https://github.com/PrivateRepo/my-private-repo.git

Of course I've scrubbed the URL here a bit, but you get the idea. Initially, the response I got back from that command was this:

fatal: unable to access 'https://github.com/PrivateRepo/my-private-repo.git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

I saw a few Stack Overflow answers talking about that but to be honest I don't really know the proper way to deal with that error. With that said, I know an improper way which is to just circumvent it completely, by running the following command:

git config --global http.sslverify false

And that seems to work. It's probably bad that I'm turning off all SSL verification, but I need to get this working, and it's not really the point of this question (which I'm getting to). But as an aside if you know the proper way to fix that I'm all ears.

Next, I re-ran my git clone command, and this time it prompted me for a username and password, but utlimately ended up failing for a different reason. Here's what it looked like:

git clone https://github.com/PrivateRepo/my-private-repo.git
Cloning into 'my-private-repo'...
Username for 'https://github.com': myuser
Password for 'https://[email protected]': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/PrivateRepo/my-private-repo.git'

However, I can assure you that the username I typed was correct, as was the password. I also have Git for Windows installed, and when I tried it there everything worked. The only caveat was that instead of prompting me for a password in the command line, it opened a separate window to enter credentials and there it also asked me for my six-digit 2FA code. Then it cloned just fine. I noticed that in doing so it created a Personal Access Token in Github. So I went ahead and created another Personal Access Token, and tried to use it manually in bash. Basically instead of typing myuser for the username I typed myuser:mytoken

git clone https://github.com/PrivateRepo/my-private-repo.git
Cloning into 'my-private-repo'...
Username for 'https://github.com': myuser:a1abcdefab2a34567ab8901a2bc3d4567890a1b2
Password for 'https://myuser:[email protected]': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/PrivateRepo/my-private-repo.git'

But as you can see it still failed. How do I get git working in bash on Windows?

1
  • Developer mode isn’t required for WSL. Why do you still have it enabled. I assume your using 1709. Authentication is failing because you disabled SSL.
    – Ramhound
    Commented Feb 28, 2018 at 21:24

2 Answers 2

5

You are using the implementation of git on your currently running linux distribution, which you probably didn't set up. try using git.exe instead:

git.exe clone https://github.com/PrivateRepo/my-private-repo.git

You can alias the command in your .bashrc:

alias git='git.exe'
1
  • this worked for me on windows 11 and wsl2 for my school github account. Commented Jan 13, 2023 at 3:31
2

You need to just use your user name and then instead of your password use your access token. You don't need your password as the token replaces it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .