Skip to content

Instantly share code, notes, and snippets.

@beastawakens
Created October 24, 2022 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beastawakens/9cdbfc454ac650e82cb43bc9fb526a3f to your computer and use it in GitHub Desktop.
Save beastawakens/9cdbfc454ac650e82cb43bc9fb526a3f to your computer and use it in GitHub Desktop.
Clone all the repos from an org to a local folder
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