git 下载代码

github为代码版本管理库,我们可以在上面建立自己的工程由服务器自动为我们管理。

但是作为小白我们最常遇见的操作是,在githua上下载大神们的代码学习学习。

下面是从github上下载代码的操作:

如果想从 github 上匿名获取某个 repo, 一般都会直接到该 repo 的网页复制网页中给的 HTTPS URL. 但是, 不知道 github 抽风还是怎么了, 获取总是报错:

$ git clone https://github.com/ideawu/ssdb.git
Initialized empty Git repository in /xxx/.git/
Cannot get remote repository information.
Perhaps git-update-server-info needs to be run there?
只好尝试使用 SSH 方式(非 github 登录用户看不到 SSH 方式的 URL):

$ git clone git@github.com:xxx/ssdb.git
Initialized empty Git repository in /xxx/ssdb/.git/
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
fetch-pack from 'git@github.com:xxx/ssdb.git' failed.
显然, 这需要输入账号和密码. 我记得 github 改版之前, 是提供了 Read-only URL 的, 不知道为什么改版之后就不提供了?! 不过, 你还是可以手工拼出只读 SSH:

git clone git://github.com/ideawu/ssdb.git
把项目的网址中的"https://"替换成"git://", 然后在末尾加上".git".

 

 

哈哈,此文为转发文档。我是为了以后查找方便,转贴过来。

致敬原帖:http://www.ideawu.net/blog/archives/745.html

posted @ 2014-11-24 11:25  安心编码  阅读(1327)  评论(0编辑  收藏  举报