Windows上的Git克隆:git@github.com不是git命令

xeufq47z  于 2023-03-31  发布在  Windows
关注(0)|答案(3)|浏览(179)

我正在尝试从github和另一个表单gitlab中以ssh方式克隆一个仓库
我在Windows上编辑:使用Git访问2.29.2.2
我得到以下错误,我不明白它是从哪里来的:

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

所以我也试过:

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

以及

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

但同样的错误出现了。
当我做ssh -v git@github.com时,我可以与成功联系起来。
我错过了什么?

xdnvmnnf

xdnvmnnf1#

首先,如果你尝试ssh://语法,那么URL应该是:

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

其次,检查是否有一个%USERPROFILE%\.ssh\config文件,其中包含一个github.com主机条目,其内容可能不正确或被误解。

rdlzhqv9

rdlzhqv92#

在我的例子中,我定义了系统环境变量GIT_SSH来使用我安装的openssh,然后git坏了,我得到了git: 'git@github.com' is not a git command. See 'git --help'.
删除系统环境变量GIT_SSH后,一切又正常了。
然后我尝试定义user环境变量GIT_SSH并重新启动系统(我在之前的尝试中没有重新启动系统),不知何故,现在我的git与我安装的openssh正常工作。我不知道我在之前的尝试中哪里出错了,但我决定不再浪费更多的时间在这上面。

z8dt9xmd

z8dt9xmd3#

更新你的git也许能帮到你!我用git update解决了这个问题。

相关问题