无需帐户即可克隆 GitHub 存储库?

38 git github

我正在整理一些文档,但无法访问未配置的机器来自己测试

我很好奇您是否需要一个 GitHub 帐户来将存储库从 GitHub 克隆到本地计算机。

小智 46

不。您只需使用不同的 URL:

git clone git://github.com/SomeUser/SomeRepo.git
Run Code Online (Sandbox Code Playgroud)

但是,本地存储库将是“只读”的,因为您将无法将更改推送回原始存储库。不过,您仍然可以在本地修改文件和提交更改。

相比之下,

git clone git@github.com:UserName/OtherRepo.git
Run Code Online (Sandbox Code Playgroud)

仅当您使用必要的 SSH 密钥等正确设置环境时才有效,但作为回报,您将获得一个存储库,允许您将更改提交/推送回远程存储库。

(抱歉无意中为 GitHub 做广告,我只是想到了。)

  • 对于 GitLab 来说是 `git clone https://gitlab.com/SomeUser/SomeRepo.git` (2认同)

小智 5

我正在关注需要从 github 克隆的产品的一些文档。我不想费心设置一个帐户,所以我需要完全按照这里的要求去做。

文档中的命令是:

git clone git://github.com/fcrepo4/fcrepo-message-consumer.git
Run Code Online (Sandbox Code Playgroud)

但这对我来说失败了。

Cloning into 'fcrepo-message-consumer'...
ssh: Could not resolve hostname github.com: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)

我试过

git clone git://github.com/fcrepo4/fcrepo-message-consumer.git
Run Code Online (Sandbox Code Playgroud)

正如其中一个答案中所建议的那样,但也失败了。

Cloning into 'fcrepo-message-consumer'...
fatal: Unable to look up github.com (port 9418) (nodename nor servname provided, or not known)
Run Code Online (Sandbox Code Playgroud)

最终奏效的是:

git clone https://github.com/fcrepo4/fcrepo-message-consumer.git
Run Code Online (Sandbox Code Playgroud)


rzr*_*rzr 5

或者只使用 http 前缀,.git 后缀也不是必需的:

您可以检查

git clone http://github.com/tizenteam/iotivity-example
Run Code Online (Sandbox Code Playgroud)

相关信息:

https://help.github.com/articles/why-is-git-always-asking-for-my-password/