Skip to content

Instantly share code, notes, and snippets.

@rickd-uk
Created February 1, 2025 06:31
Show Gist options
  • Save rickd-uk/fcc69759794d25a7262f93bc494a4adf to your computer and use it in GitHub Desktop.
Save rickd-uk/fcc69759794d25a7262f93bc494a4adf to your computer and use it in GitHub Desktop.
Clone All Public Repos from URL
#!/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