Skip to content

Instantly share code, notes, and snippets.

@SafeEval
Created December 23, 2023 20:08
Show Gist options
  • Save SafeEval/0ad07109a273015af0976c54366e0df0 to your computer and use it in GitHub Desktop.
Save SafeEval/0ad07109a273015af0976c54366e0df0 to your computer and use it in GitHub Desktop.
Clone all active (non-archived) repos from an organization.
#!/bin/bash
export GITHUB_TOKEN=""
export GITHUB_ORG=""
gh repo list "$GITHUB_ORG" --no-archived --limit 1000 > repo-list.txt
for repo_path in $(cat repo-list.txt | cut -f1); do
org="$(echo $repo_path | cut -f1 -d'/')"
repo="$(echo $repo_path | cut -f2 -d'/')"
if [ ! -d "$repo" ]; then
echo "#################################################"
echo "$repo: Cloning."
git clone "git@github.com:$repo_path";
fi
done
du -d1 -h | sort -hr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment