我已经在我的 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 工作?
最佳答案
我使用的是一台没有设置 SSH 的 Windows 机器,所以唯一设置的 SSH key 是由 github 安装程序设置的。在我的 .ssh 目录中,我有一个 github_rsa 和 github_rsa.pub 文件,但没有默认的 ssh key id_rsa 和 id_rsa.pub。 Github 客户端(包括 shell 和 GUI)在与 github.com 通信时会使用 github_rsa(.pub) 组合键,但是在标准 Windows 命令行中运行的 git 需要 id_rsa(.pub) 组合。
为了解决这个问题,我简单地复制了一个 github_rsa 私钥,并为其指定了默认名称“id_rsa”。同样,我将 github_rsa.pub key 复制到“id_rsa.pub”。这样做之后,git.exe 也可以从 Windows 命令行运行。
关于windows - git clone 在 git shell 中工作,但在 windows 命令行中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28074682/