Blog
Cloning all my GitHub repos faster than the default
A Bash + Git + jq script to fetch every repo I own with submodules, handling pagination and dry-run previews.
Why #
I wanted a faster, zero-click way to back up every GitHub repo I own, including submodules, without relying on the GitHub UI. The goal: a single command that pulls everything down (or simulates it) using SSH.
What I built #
- Bash script using
curl+ GitHub API +jqto list all repos (with pagination). - Clones via
git clone --recurse-submodulesto keep submodules in sync. --dry-runflag to preview what would be cloned without touching disk.- Skips already-present repos to avoid redundant work.
How it works (high level) #
- Requires
GITHUB_TOKENwith repo metadata read access; uses SSH for cloning. - Fetches paginated repo lists via GitHub API, writes targets into a loop.
- For each repo: clone with submodules if missing; otherwise skip.
- Optional dry-run prints planned actions only.
Notes #
- Set
GITHUB_TOKENin your environment and ensuressh-agentis running with your key added. - Configure
CLONE_DIRin the script to choose where backups land. - Designed for Linux/macOS with Bash + curl + jq + git available.