Last active
January 8, 2023 20:17
-
-
Save Mearman/d6513364a8a3af721d63fcba95c3a83f to your computer and use it in GitHub Desktop.
github_clone_all.sh
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 | |
| # 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