A shell script that allows you to list and delete repositories from your GitHub account with an interactive interface.
- 🔍 List all repositories - View all your GitHub repositories with details
- 🗑️ Selective deletion - Choose specific repositories to delete
⚠️ Safety confirmations - Multiple confirmation prompts to prevent accidental deletions- 🎨 Colored output - Easy-to-read interface with color-coded messages
- 🔒 Secure authentication - Uses GitHub Personal Access Tokens
- 📊 Deletion summary - Shows success/failure statistics
Before using this script, you need to install the following dependencies:
brew install curl jqsudo apt-get update
sudo apt-get install curl jqsudo yum install curl jq- Go to GitHub Settings > Personal Access Tokens
- Click "Generate new token" → "Generate new token (classic)"
- Give it a descriptive name (e.g., "Repository Manager")
- Select the following scopes:
repo(for private repositories) ORpublic_repo(for public repositories only)delete_repo(for repository deletion)
- Click "Generate token"
- Important: Copy the token immediately - you won't be able to see it again!
You can provide your GitHub token in two ways:
export GITHUB_TOKEN="your_personal_access_token_here"The script will ask for your token if it's not found in the environment.
./github_repo_manager.shGITHUB_TOKEN="your_token_here" ./github_repo_manager.sh- Start the script - The script will check dependencies and ask for your GitHub credentials
- Test connection - It verifies your token and username
- Main menu - Choose from the following options:
- Option 1: List all repositories
- Option 2: Delete repositories (includes listing and selection)
- Option 3: Exit
When you choose to delete repositories:
- List repositories - Shows all your repositories with IDs, names, privacy status, and last updated date
- Select repositories - Enter repository IDs separated by commas, or type:
all- to select all repositoriesnone- to cancel the operation
- Confirm deletion - Review the list of repositories to be deleted
- Final confirmation - Type
yesto proceed with deletion - Deletion summary - Shows how many repositories were successfully deleted
=== Your GitHub Repositories ===
123456789 | my-awesome-project | Public | 2024-01-15 14:30
987654321 | private-repo | Private | 2024-01-14 09:15
456789123 | test-repo | Public | 2024-01-13 16:45
================================
Select repositories to delete:
Enter repository IDs separated by commas (e.g., 1,3,5)
Or enter 'all' to select all repositories
Or enter 'none' to cancel
Selection: 123456789,456789123
=== REPOSITORIES TO BE DELETED ===
- yourusername/my-awesome-project
- yourusername/test-repo
===================================
⚠️ WARNING: This action cannot be undone!
These repositories will be permanently deleted from GitHub.
Are you sure you want to proceed? (yes/no): yes
Starting deletion process...
Deleting: yourusername/my-awesome-project...
✓ Successfully deleted: yourusername/my-awesome-project
Deleting: yourusername/test-repo...
✓ Successfully deleted: yourusername/test-repo
=== Deletion Summary ===
Successfully deleted: 2 repositories
- Multiple confirmations - You must confirm deletion twice
- Clear warnings - The script warns you that deletion is irreversible
- Repository validation - Only valid repository IDs are processed
- Error handling - Failed deletions are reported separately
- Rate limiting - Small delays between deletions to avoid API limits
-
"Missing required dependencies"
- Install
curlandjqusing the commands in the Prerequisites section
- Install
-
"Invalid token" or "HTTP 401"
- Check that your GitHub token is correct
- Ensure the token has the required scopes (
repoorpublic_repo, anddelete_repo)
-
"HTTP 403" (Forbidden)
- Your token might not have sufficient permissions
- Make sure you have
delete_reposcope enabled
-
"Repository not found"
- The repository might have been deleted already
- Check that you're using the correct repository ID
If you encounter issues:
- Check that your GitHub token has the correct permissions
- Verify that the repositories you're trying to delete actually exist
- Make sure you have the required dependencies installed
- Check your internet connection
- Never share your GitHub token - It provides full access to your repositories
- Use environment variables - Don't hardcode tokens in scripts
- Revoke unused tokens - Delete tokens you no longer need
- Review permissions - Only grant the minimum required scopes
This script is provided as-is for educational and personal use. Use at your own risk.