Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

@haniokasai

GitHubから組織のすべての公開リポジトリをgit cloneする方法

自分の過去のブログ から。

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?