Skip to content

Instantly share code, notes, and snippets.

@blackstar257
Created March 26, 2024 04:39
Show Gist options
  • Save blackstar257/83a43622042e5d12108fdfdb51433214 to your computer and use it in GitHub Desktop.
Save blackstar257/83a43622042e5d12108fdfdb51433214 to your computer and use it in GitHub Desktop.
gh repo list myorgname --limit 1000 | while read -r repo _; do
gh repo clone "$repo" "$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