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

时间:2014-02-03 16:21:59

标签: git github

为什么git://有效

$ git clone git://github.com/schacon/grit.git
Cloning into 'grit'...
...
Checking connectivity... done.

但是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.

感谢任何帮助

2 个答案:

答案 0 :(得分:11)

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

答案 1 :(得分:4)

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

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

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

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

您可以在这里看到与github相关的协议之间的差异:

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

相关问题