Created
October 24, 2022 13:11
-
-
Save beastawakens/9cdbfc454ac650e82cb43bc9fb526a3f to your computer and use it in GitHub Desktop.
Clone all the repos from an org to a local folder
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
gh repo list {ORGANISATION_NAM} --limit 1000 | while read -r repo _; do | |
gh repo clone "$repo" -- -q 2>/dev/null || ( | |
cd "$repo" | |
# Handle case where local checkout is on a non-main/master branch | |
# - ignore checkout errors because some repos may have zero commits, | |
# so no main or master | |
git checkout -q main 2>/dev/null || true | |
git checkout -q master 2>/dev/null || true | |
git pull -q | |
) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment