3

I'm trying to clone a repository the ssh way from github and another form gitlab

I'm on windows EDIT : with Git v 2.29.2.2

I'm getting the following error, which I do not understand from what it is coming from :

$ git clone git@github.com:math-gallou/AI21_TPs.git
Cloning into 'AI21_TPs'...
git: 'git@github.com' is not a git command. See 'git --help'.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

So I also tried :

$ git clone "ssh://git@github.com:math-gallou/AI21_TPs.git"

and

$ git clone ssh://git@github.com:math-gallou/AI21_TPs.git

But the same exact error comes out.

When I do the ssh -v git@github.com I can connect with success.

So what did I miss ?

mathoug
  • 31
  • 1
  • 4
  • What version of Git-for-Windows do you have installed? – Dai Nov 29 '20 at 14:27
  • Hint (perhaps of no help, but anyway): for `ssh://` URLs the syntax is slightly different: `git clone ssh://git@github.com/math-gallou/AI21_TPs.git` (slash `/` instead of colon `:`). See https://git-scm.com/docs/git-fetch#_git_urls – phd Nov 29 '20 at 14:32

3 Answers3

1

First, if you are trying the ssh:// syntax, then the URL would be:

git clone ssh://git@github.com/math-gallou/AI21_TPs.git
                            ^^^ /, not :

Second, check if you have a %USERPROFILE%\.ssh\config file with a github.com Host entry in it, whose content might be incorrect or mis-interpreted.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So I first tried the syntax you gave me, but the exact same error still shows. Second, I do not have this config file, ima look for what it is and what it should contain – mathoug Dec 01 '20 at 09:13
  • @mathoug OK, how about the config file? – VonC Dec 01 '20 at 09:17
  • hi @VonC. I did the config file following this post : https://stackoverflow.com/questions/56287059/how-to-set-up-an-ssh-config-file-for-beginners. It changes absolutely nothing. With a friend, we are thinking of a weird alias somewhere somehow ? But I tried to clean my git install (deleting and reinstalling everything) and it's still the same ... :/ – mathoug Dec 03 '20 at 11:18
  • @mathoug Can you try with a simplified PATH? (as in https://stackoverflow.com/a/63835684/6309) – VonC Dec 03 '20 at 11:33
  • It's worse haha, now I get `bash: git: command not found` – mathoug Dec 04 '20 at 07:44
  • @mathoug I promise you, a simplified PATH is made to reference git, so double-check your PATH. Make sure `GH` is pointing to your Git installation folder. – VonC Dec 04 '20 at 07:46
0

In my case, I defined system environment variable GIT_SSH to use openssh I installed, and then git is broken and I got git: 'git@github.com' is not a git command. See 'git --help'..

After deleting system environment variable GIT_SSH everything works again.

Then I tried to define user environment variable GIT_SSH and restart system (I didn't restart system in previous try), somehow now my git works correctly with openssh I installed. I don't know which part is wrong in my previous try but I decide not to waste more time on this.

Dharman
  • 30,962
  • 25
  • 85
  • 135
An07
  • 101
  • 1
  • 1
  • 5
0

Update your git maybe help you! I solved the problem by using git update.