This gist provides different approaches to delete all labels from a GitHub repository using the GitHub CLI (gh).
# ❌ This doesn't work - gh doesn't support wildcards
gh label delete *The GitHub CLI doesn't support wildcard deletion, so we need alternative approaches.
gh label list --json name --jq '.[].name' | xargs -I {} gh label delete {} --yesWhat this does:
gh label list --json name- Gets all labels in JSON format with only the name field--jq '.[].name'- Extracts just the label names using jqxargs -I {} gh label delete {} --yes- Runs delete command for each label with auto-confirmation
# First, see what labels exist
gh label list
# Then delete all labels
gh label list --json name --jq '.[].name' | xargs -I {} gh label delete {} --yesgh label list --json name --jq '.[].name' | xargs -I {} gh label delete {}This will prompt you to confirm each deletion individually.
# Save label names to a file
gh label list --json name --jq '.[].name' > labels.txt
# Review the file
cat labels.txt
# Delete all labels from the file
cat labels.txt | xargs -I {} gh label delete {} --yes
# Clean up
rm labels.txt- GitHub CLI (
gh) must be installed and authenticated - You need admin permissions on the repository
jqmust be installed for JSON parsing
If some labels fail to delete, you can identify which ones remain:
# Check remaining labels
gh label list
# Delete specific labels manually
gh label delete "label-name" --yesIf you want to restore GitHub's default labels after deletion:
# GitHub doesn't have a built-in restore, but you can recreate common ones
gh label create "bug" --description "Something isn't working" --color "d73a4a"
gh label create "enhancement" --description "New feature or request" --color "a2eeef"
gh label create "documentation" --description "Improvements or additions to documentation" --color "0075ca"- Always run
gh label listfirst to see what you're working with - Consider backing up your labels before mass deletion
- The
--yesflag skips confirmation prompts - use carefully - If you have many labels, the operation might take a few seconds
Created for efficient GitHub repository management