为什么git://有效,但git @没有

Hai*_*Liu 11 git github

为什么git://有效

$ git clone git://github.com/schacon/grit.git
Cloning into 'grit'...
...
Checking connectivity... done.
Run Code Online (Sandbox Code Playgroud)

但是git @没有

$ git clone git@github.com:schacon/grit.git mygrit
Cloning into 'mygrit'...
Warning: Permanently added the RSA host key for IP address '192.30.252.129' to t
he list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏

lon*_*elk 11

这是因为git @使用ssh协议.它相当于ssh:// git @ ..所以如果你没有正确的ssh密钥它将无法工作.选项git://然而使用git协议,它类似于ssh但根本不使用任何身份验证.有关更多信息,请参阅协议章节.


sja*_*ski 5

第一个克隆方法是使用 git 协议,第二个是使用 SSH。

您可能没有在 github.com 上设置 SSH 令牌

https://help.github.com/articles/generate-ssh-keys

为您提供有关如何设置用户帐户以供 SSH 使用的步骤。

您可以在此处查看与 github 相关的协议之间的差异:

https://gist.github.com/grawity/4392747