Skip to content

Instantly share code, notes, and snippets.

@jimdiroffii
Last active October 23, 2024 02:37
Show Gist options
  • Save jimdiroffii/4e3b240774f8e0cfc91813e715fc6c7a to your computer and use it in GitHub Desktop.
Save jimdiroffii/4e3b240774f8e0cfc91813e715fc6c7a to your computer and use it in GitHub Desktop.
Clone all personal repos using PowerShell or Bash
# Install Github CLI
winget install -e --id GitHub.cli
# Log into Github
gh auth login
mkdir c:\_all
cd c:\_all
gh repo list | ForEach-Object { gh repo clone $_.Split("`t")[0] }
@jimdiroffii
Copy link
Author

Bash script:

gh repo list <your-username> --limit 1000 --json name,sshUrl | jq -r '.[] | .sshUrl' | while read repo; do
    repo_name=$(basename "$repo" .git)
    if [ ! -d "$repo_name" ]; then
        git clone "$repo"
    else
        echo "Repository $repo_name already exists, skipping..."
    fi
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment