Skip to content

Instantly share code, notes, and snippets.

@shedali
Last active July 3, 2023 08:36
Show Gist options
  • Save shedali/a5cbbe8dfc95795b93d7a239af22d023 to your computer and use it in GitHub Desktop.
Save shedali/a5cbbe8dfc95795b93d7a239af22d023 to your computer and use it in GitHub Desktop.
clone all org repos
export GITHUB_TOKEN=$(op plugin run gh auth token)
for org in $(gh org list); do
o=${org}
/usr/local/bin/op plugin run -- gh repo list $o --json name -q '.[] | .name' | while read -r repo; do
dir=$o/$repo
echo $dir
if [ -d "$dir" ]; then
(cd $dir && git stash --all && gh repo sync && git stash pop)
else
gh repo clone $dir $dir
fi
done;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment