gh repo list <org/user/etc> --limit 1000 | while read -r repo _; do gh repo clone "$repo" "$repo" done
The limit
is added to stop accidentally cloning a large organisation like Microsoft.
A modified version that also pulls master
or main
at the same time:
gh repo list <org/user/etc> --limit 1000 | while read -r repo _; do gh repo clone "$repo" "$repo" -- -q 2>/dev/null || ( cd "$repo" # Handle case where local checkout is on a non-main/master branch # - ignore checkout errors because some repos may have zero commits, # so no main or master git checkout -q main 2>/dev/null || true git checkout -q master 2>/dev/null || true git pull -q ) done
ghorg
can also be used, but requires a bit more setup.
https://stackoverflow.com/questions/19576742/how-to-clone-all-repos-at-once-from-github