自分の過去のブログ から。
githubからorganizationのすべてのリポジトリをgit cloneする方法
githubのプライベートリポジトリをブルーレイにバックアップしようと思ったので、調べてみた。
あくまでも組織のみの場合です。ユーザーの場合は api.github.com/orgs を api.github.com/usersに変えるように。
gitbp.sh
#/bin/sh
username=*****
password=******
oauthtoken=***
ORGANIZATION=ダウンロードしたい組織名
mkdir $ORGANIZATION;
cd $ORGANIZATION;
for i in `curl -u $username:$oauthtoken -s https://api.github.com/orgs/$ORGANIZATION/repos?per_page=200 |grep html_url|awk 'NR%2 == 0'|cut -d ':' -f 2-3|tr -d '",'`; do
expect -c "
set timeout 20
spawn git clone $i.git
expect \"Username for \'https://github.com\':\"
send \"$username\n\"
expect \"Password for \'https://$username@github.com\':\"
send \"$password\n\"
interact
";
done
ユーザーの公開リポジトリは
gitbp.sh
#/bin/sh
ORGANIZATION=******
mkdir $ORGANIZATION;
cd $ORGANIZATION;
for i in `curl -s https://api.github.com/users/$ORGANIZATION/repos?per_page=200 |grep html_url|awk 'NR%2 == 0'|cut -d ':' -f 2-3|tr -d '",'`; do
git clone $i.git;
done
でできます
参考
https://gist.github.com/caniszczyk/3856584
http://futurismo.biz/archives/1357