-1

用来克隆别人的仓库的正确 url 是什么?

  • 我可以做到:git clone https://github.com/other-user/repo.git但这让我在推送时输入我的用户名/密码。
  • 我试过了:git clone git@github.com:my-username/other-user/repo.git 但它没有用
4

2 回答 2

1

使用正确的克隆网址

我试过: git clone git@github.com:my-username/other-user/repo.git

存储库 url 不会根据您的身份而改变 - 它始终相同。当通过 ssh 克隆时,后面的位:指示存储库 - 即远程系统上存储库的路径。

如果有疑问,请转到https://github.com/other-user/repo,然后从SSH clone URL框中复制 url。从 github 获取 url 也将确认/确保您可以访问存储库。正确的克隆 URL 将采用以下形式:

git clone git@github.com:other-user/repo.git

my-username不会在其中。

请注意,如果您有现有的结帐,则无需再次克隆 - 您只需更改.git/config文件中远程的 url。

于 2013-07-19T15:01:53.277 回答
0

如果您是合作者,您可以使用以下两种选择中的任何一种:

git clone https://YOUR_USERNAME@github.com/torvalds/linux.git
git clone git@github.com:torvalds/linux.git

在第一种情况下,您可以省略,但几乎每个//YOUR_USERNAME都会提示您输入用户名和密码。您可以通过在文件中创建这样的规则来完全避免被问到这个问题,但更安全的是使用凭证助手来缓存它,因此您必须不时输入您的凭证。fetchpullpush.netrc

使用 SSH URL,您只需通过密钥进行身份验证。


如果您不是存储库的协作者(即,您没有对存储库的推送访问权限),您可以使用 GitHub UI 提供的 3 种替代方案中的任何一种:

git clone https://github.com/torvalds/linux.git
git clone git@github.com:torvalds/linux.git
git clone http://github.com/torvalds/linux.git

(我认为最后一个已被弃用)。

您可以在此 GitHub 的帮助文章中了解每种方法的区别和好处。

于 2013-07-19T04:21:25.360 回答