Copy all Repos from Github

How to Clone All Your GitHub Repositories with a Single Command

Steps

Github has an API that you can use

grep the full_name field to get a list of all the repos

cut the relevant details to extract a neat list

Use xargs with substitution to clone the repos

curl "https://api.github.com/{user|orgs}/{username|orgname}/repos?page=1&per_page=100" \
-H "Accept: application/vnd.github.v3+json" \
-H"Authorization: token YOUR_TOKEN"  \
| grep -e 'full_name' \
| cut -d \" -f 4 \
| xargs -L1 -I{} git clone git@github.com:{}

This workflow combines several powerful command-line tools - for more text processing techniques, check out my LogSeq extraction guide and audio transcription with ffmpeg.

Usecase

I wanted to explore all my repos hosted on Github on my local machine instead.

The above command made it easy to dump the repos on my local machine. For more command-line text processing techniques, check out Recursively search and replace text in all files in MacOS and Extracting information out of logseq.