git clone 在 git shell 中可以运行,但在 Windows 命令行中无法运行。

3

我已经在我的Windows电脑上安装了Github客户端工具。如果我尝试从git shell使用git,它可以正常工作。但是,如果我尝试从Windows命令行使用它,它会失败:

c:\git\test>git clone git@github.com:myusername/myrepo.git
Cloning into 'myrepo'...
Permission denied (publickey).
fatal: Could not read from remote repository.

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

我会使用git shell,但我需要设置命令行与bower一起工作。还需要设置什么才能让git正常工作?


你需要检查对 RSA 公钥的权限。 - Konrad Krakowiak
1个回答

6
我正在使用一台没有设置SSH的Windows机器,所以唯一设置的SSH密钥是由GitHub安装程序设置的。在我的.ssh目录中,我有一个github_rsa和github_rsa.pub文件,但没有默认的id_rsa和id_rsa.pub SSH密钥。GitHub客户端(包括shell和GUI)在与github.com通信时将使用github_rsa(.pub)密钥组合,但在标准的Windows命令行中运行的git需要id_rsa(.pub)密钥组合。
为了解决这个问题,我简单地复制了github_rsa私钥,并将其命名为"id_rsa"。同样,我将github_rsa.pub密钥复制到"id_rsa.pub"。这样做后,git.exe也可以在Windows命令行中运行。

那对我也起作用了。 我简直不敢相信Windows有如此荒谬的行为。 非常感谢你。 - Víctor Hugo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接