Skip to content

Instantly share code, notes, and snippets.

@bplaat
Created March 5, 2026 17:21
Show Gist options
  • Select an option

  • Save bplaat/4b728eb94e6b1066d6123b0d2469fc4f to your computer and use it in GitHub Desktop.

Select an option

Save bplaat/4b728eb94e6b1066d6123b0d2469fc4f to your computer and use it in GitHub Desktop.
GitHub clone script - clones all repos from an org or user
#!/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