Skip to content

Instantly share code, notes, and snippets.

@mwthink
Last active July 28, 2020 00:12
Show Gist options
  • Save mwthink/2eee4b753d2bf8ce08392be15d11b64a to your computer and use it in GitHub Desktop.
Save mwthink/2eee4b753d2bf8ce08392be15d11b64a to your computer and use it in GitHub Desktop.
Github Repo Deletion Script
#!/bin/bash
# Use this to delete github repos easily
# Be extremely careful, you can make big mistakes easily with this!
# https://github.com/settings/tokens
ACCESS_TOKEN=""
# List repos
GIT_REPOS=$(curl -s \
-H "Authorization: token ${ACCESS_TOKEN}" \
https://api.github.com/user/repos | jq '.[].full_name' | jq -scr '. + ["exit"] | .[]')
echo "enter 0 to exit"
select REPO in $GIT_REPOS; do
if [[ -z ${REPO} ]]; then
echo "no good selection"
exit 1
fi
if [ "${REPO}" == "exit" ]; then
echo "Exiting"
exit
fi
curl -s -X DELETE -H "Authorization: token ${ACCESS_TOKEN}" https://api.github.com/repos/${REPO}
echo "Deleted ${REPO}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment