Skip to content

Instantly share code, notes, and snippets.

@Mearman
Last active January 8, 2023 20:17
Show Gist options
  • Select an option

  • Save Mearman/d6513364a8a3af721d63fcba95c3a83f to your computer and use it in GitHub Desktop.

Select an option

Save Mearman/d6513364a8a3af721d63fcba95c3a83f to your computer and use it in GitHub Desktop.
github_clone_all.sh
#!/bin/bash
# Check if an organization name was provided
if [ -z "$1" ]; then
echo "Error: No organization name provided."
exit 1
fi
# Set the organization name
ORG_NAME="$1"
# Set the destination directory
DEST_DIR="/path/to/destination/directory"
# Create the destination directory if it doesn't exist
mkdir -p "$DEST_DIR"
# Change into the destination directory
cd "$DEST_DIR"
# Get a list of all the repositories for the organization
repos=$(curl -s "https://api.github.com/orgs/$ORG_NAME/repos?per_page=200" | jq -r '.[].clone_url')
# Clone each repository
for repo in $repos; do
git clone "$repo"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment