as a guy that wants to automate everything I am wondering how I can automaticly download all my private and public repositorys to my disk using the github public api(v3) under linux. Using /bin/sh.
greetings
It's a somewhat hacky solution and I'm somewhat eager to see a clean solution of that. Anyway, maybe someone could need this as well and since I did not find an soltuion online I'll explain it shortly.
The raw code you can execute can be found here: https://gist.github.com/Pierrefha/0436e7bf907d5ed794fe489b06bbac14
First we are using curl to get the list of all public and private repos.
curl -u USERNAME:TOKENVALUE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/repos
Then we select only the lines that contain the git url.
grep git_url
now we replace anything before .com with and the ", at the end with an empty string
sed -E sQ.*.com\/\|\",QQg
Last but not least we take the remaining string(exact name of our repos) and use xargs to clone the repos.
xargs -I% git clone git@github.com:%
And we're done.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.