Last active
May 22, 2021 14:14
-
-
Save mijdavis2/bdd1c30905dad8302cdb490b5687297a to your computer and use it in GitHub Desktop.
Clone all repos from org or user via gh cli (GitHub cli)
This file contains 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 | |
# | |
# Requires `gh` --> https://cli.github.com/ | |
# | |
# Ensure you setup gh cli via `gh auth login` | |
# and select the `ssh` option if you are cloning private repos - much easier. | |
# | |
# Usage: | |
# $ ./clone-repos.sh some_org target_dir | |
# Cloning into 'target_dir/some_repo'... | |
# | |
gh repo list "$1" --limit 1000 | while read -r repo _; do | |
repo_name=$(echo "$repo" | grep -oP "^$1\K.*") | |
gh repo clone "$repo" "$2$repo_name" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment