Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从单个作者快速下载多个github项目_Git_Github_Download_Bulk - Fatal编程技术网

如何从单个作者快速下载多个github项目

如何从单个作者快速下载多个github项目,git,github,download,bulk,Git,Github,Download,Bulk,github的作者有很多小项目或大项目。我怎样才能在不点击浏览器中的每个项目(如批量下载)的情况下快速下载它们呢?使用shell。签出存储库的命令是git clone。您可以编写一个循环,该循环多次运行git clone,对于列表中的每个元素运行一次。如果列表包含存储库的名称,则循环非常简单: for repo in foo bar baz; do git clone git@github.com:username/${repo}.git; done 结果将是每个命名存储库的克隆 注意:我假设

github的作者有很多小项目或大项目。我怎样才能在不点击浏览器中的每个项目(如批量下载)的情况下快速下载它们呢?

使用shell。签出存储库的命令是
git clone
。您可以编写一个循环,该循环多次运行
git clone
,对于列表中的每个元素运行一次。如果列表包含存储库的名称,则循环非常简单:

for repo in foo bar baz; do git clone git@github.com:username/${repo}.git; done
结果将是每个命名存储库的克隆

注意:我假设您使用的是bashshell。默认情况下,几乎所有操作系统都使用bash,但Windows不使用。这就是为什么当你在windows上安装Git时,你也在安装BashShell;它在“开始”菜单中被称为“Git Bash”。

我发现这很有用:

总结:

在OSX上的终端中键入以下任一项 使用ssh:

curl -s https://api.github.com/orgs/googlesamples/repos | ruby -rjson -e 'JSON.load(STDIN.read).each {|repo| %x[git clone #{repo[“ssh_url"]} ]}'
使用克隆url(如果未设置ssh密钥或存在ssh问题):

在上面的示例中,我从“googlesamples”页面()下载了所有存储库

因此,您应该将url替换为您试图获取其repo的作者的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页面是值得的

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"]} ]}'