Created
February 1, 2025 06:31
-
-
Save rickd-uk/fcc69759794d25a7262f93bc494a4adf to your computer and use it in GitHub Desktop.
Clone All Public Repos from URL
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 | |
clone_all_repos() { | |
local username="$1" | |
# Check if the username is provided | |
if [ -z "$username" ]; then | |
echo "Error: GitHub username not provided." | |
return 1 | |
fi | |
# Get the list of repositories | |
repos=$(curl -s https://api.github.com/users/$username/repos?per_page=200 2>/dev/null | jq '.[].clone_url' | tr -d '"') | |
if [ $? -ne 0 ]; then | |
echo "Error: Failed to fetch repository list for $username." | |
return 1 | |
fi | |
# Clone each repository | |
for repo in $repos; do | |
git clone "$repo" 2>/dev/null | |
if [ $? -ne 0 ]; then | |
echo "Error: Failed to clone $repo." | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment