批量拉取github组织或者用户的仓库

#!/bin/bash

git_host="https://github.com"
tmp_log="tmp_repos.log"


function gitclone()
{
  username=$1
  if [ ! -d $username ];then
  	mkdir -p $username
  fi
  cd $username
  if [ -f $tmp_log ];then
  	rm $tmp_log
  fi

  curl https://api.github.com/orgs/linuxdeepin/repos?per_page=100&page=1 | grep -o 'git@[^"]*' > $tmp_log
  curl https://api.github.com/orgs/linuxdeepin/repos?per_page=100&page=2 | grep -o 'git@[^"]*' >> $tmp_log
  curl https://api.github.com/orgs/linuxdeepin/repos?per_page=100&page=3 | grep -o 'git@[^"]*' >> $tmp_log

  cat $tmp_log | while read line
	do
        # 找到仓库的名字
        name=$(basename $line)
        # 方式一:下载zip包
        #wget https://codeload.github.com$line/zip/master -O $name.zip
        # 方式二:git clone 
        git clone $line
	done
  rm $tmp_log
}

gitclone $1

视仓库数量分页数增加,这里简单写了
另外github右限制,重复请求有数量限制
https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting
对于使用基本身份验证或 OAuth 的 API 请求,您每小时最多可以发出 5,000 个请求。无论使用的是基本身份验证还是OAuth 令牌,经过身份验证的请求都与经过身份验证的用户相关联。这意味着当一个用户授权的所有 OAuth 应用程序使用同一用户拥有的不同令牌进行身份验证时,它们共享相同的配额,即每小时 5,000 个请求。
有说更新令牌可以继续拉,试过失败了,
https://github.com/settings/tokens/new

拉取脚本参考:
https://blog.csdn.net/qq_23091073/article/details/83117158
https://stackoverflow.com/questions/8713596/how-to-retrieve-the-list-of-all-github-repositories-of-a-person
官网仓库说明:
https://docs.github.com/en/rest/reference/repos

原文地址:https://www.cnblogs.com/kuikuitage/p/14998598.html