如何快速下载单个作者的多个github项目
答
使用shell。检出存储库的命令是git clone <repourl>
。您可以编写一个循环,该循环多次运行git clone
,每个元素在列表中一次。如果列表中包含存储库的名称,则循环很简单:
for repo in foo bar baz; do git clone [email protected]:username/${repo}.git; done
结果将是每个命名的存储库的克隆。
注意:我假定你使用的是bash shell。几乎所有的操作系统都默认使用bash,但Windows不支持。这就是为什么当你在Windows上安装Git时,你还要安装bash shell;它在开始菜单中被称为“Git Bash”。
答
我发现这个有用:http://www.aheritier.net/clone-all-repositories-from-a-github-organization/
汇总:
键入以下任一插入OSX 终端使用SSH的:用克隆URL(如果你没有
curl -s https://api.github.com/orgs/googlesamples/repos | ruby -rjson -e 'JSON.load(STDIN.read).each {|repo| %x[git clone #{repo[“ssh_url"]} ]}'
你的SSH密钥设置或者你是否有ssh问题):
curl -s https://api.github.com/orgs/googlesamples/repos | ruby -rjson -e 'JSON.load(STDIN.read).each {|repo| %x[git clone #{repo[“clone_url"]} ]}'
在上例中,我从“googlesamples”页面(https://github.com/googlesamples)下载了所有存储库。
因此,您应该将URL替换为您试图获得的作者URL。
编辑:
超过30个库,您必须指定每页回购的页面和数量:
https://api.github.com/orgs/googlesamples/repos?page=1&per_page=100
编辑:所以下载100个回购的第一页:
curl -s 'https://api.github.com/orgs/googlesamples/repos?page=1&per_page=100' | ruby -rjson -e 'JSON.load(STDIN.read).each {|repo| %x[git clone #{repo["clone_url"]} ]}'
虽然我上面指定的链接是有用的,只是访问github api页面是值得的..