Created
March 5, 2026 17:21
-
-
Save bplaat/4b728eb94e6b1066d6123b0d2469fc4f to your computer and use it in GitHub Desktop.
GitHub clone script - clones all repos from an org or user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # GitHub clone script - clones all repos from an org or user | |
| # Usage: ./gh_clone.sh [github-org-or-user] | |
| # If no argument provided, uses authenticated user | |
| set -e | |
| GITHUB_ORG="${1}" | |
| if [ -z "$GITHUB_ORG" ]; then | |
| echo "No organization/user provided. Getting authenticated user..." | |
| GITHUB_ORG=$(gh api user --jq '.login') | |
| echo "Using authenticated user: $GITHUB_ORG" | |
| fi | |
| echo "Cloning all repositories from: $GITHUB_ORG" | |
| echo "" | |
| # Get all repos for the org/user with full names | |
| gh repo list "$GITHUB_ORG" --limit 1000 --json nameWithOwner --jq '.[] | .nameWithOwner' | while read repo; do | |
| echo "Cloning: $repo" | |
| gh repo clone "$repo" "$repo" -- --quiet || echo "Failed to clone $repo" | |
| done | |
| echo "" | |
| echo "Clone complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment