- Install Homebrew: https://brew.sh/
- Install Github CLI: https://cli.github.com/
Linux
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install gh
Linux
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install gh
# Back up all repositories starting with a certain set of characters. | |
# | |
# Replace `<GithubAccountName>/...` with the start of the repo(s) you want to remove. e.g. Jerdak/foo_ | |
gh repo list --json nameWithOwner --jq '.[] | select(.nameWithOwner | startswith("<GithubAccountName>/...")) | .nameWithOwner' | | |
while read -r repo; do | |
owner=$(echo "$repo" | cut -d '/' -f 1) | |
repo_name=$(echo "$repo" | cut -d '/' -f 2) | |
gh repo clone "$owner/$repo_name" | |
cd "$repo_name" | |
tar czf "../${repo_name}.tar.gz" . | |
cd .. | |
rm -rf "$repo_name" | |
done |
# Delete all repositories starting with a certain set of characters | |
# | |
# Replace `<GithubAccountName>/...` with the start of the repo(s) you want to remove. e.g. Jerdak/foo_ | |
gh repo list --json nameWithOwner --jq '.[] | select(.nameWithOwner | startswith("Jerdak/difz")) | .nameWithOwner' | | |
while read -r repo; do | |
owner=$(echo "$repo" | cut -d '/' -f 1) | |
repo_name=$(echo "$repo" | cut -d '/' -f 2) | |
echo "Deleting: $owner/$repo_name" | |
# UNCOMMENT ME TO ACTUALLY DELETE (will require `gh auth refresh -s delete_repo` to have been run at least once) | |
#gh repo delete "$owner/$repo_name" --yes | |
done |