LoginSignup
2
0

More than 5 years have passed since last update.

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

Last updated at Posted at 2019-03-31

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

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

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0