A zsh script for creating and deleting GitHub repositories in bulk. This is purely for testing creating GitHub repos from the command line.
- 🚀 Bulk Repository Creation: Create multiple GitHub repositories with a single command (with numbered indices)
- 📥 Automatic Cloning: Optionally clone repositories to your local machine as they're created
- 🧹 Bulk Cleanup: Delete multiple repositories with the same ease
- 🏷️ Flexible Naming: Use custom prefixes for organized repository naming
- 🏢 Organization Support: Works with both personal and organization repositories
- ⚡ Rate Limiting Protection: Built-in delays to respect GitHub API limits
- 📊 Progress Tracking: Real-time feedback with success/failure indicators
- 🛡️ Error Handling: Comprehensive error checking and reporting
-
GitHub CLI: Install the GitHub CLI tool
# macOS brew install gh # Other platforms: https://cli.github.com/
-
Authentication: Authenticate with GitHub
gh auth login
-
Delete Permissions (for cleanup): If you plan to use the
--clean
optiongh auth refresh -h github.com -s delete_repo
-
Clone or download the script:
curl -O https://raw.githubusercontent.com/your-repo/gh-bulk-repo.zsh
-
Make it executable:
chmod +x gh-bulk-repo.zsh
./gh-bulk-repo.zsh [count] [prefix] [--clone] [--clean]
count
(optional): Number of repositories to create/delete (default: 1)prefix
(optional): Prefix for repository names (default: "test-repo")--clone
(optional): Clone repositories after creation--clean
(optional): Delete repositories instead of creating them
Repositories are named using the pattern: {prefix}-{number}
Examples:
test-repo-1
,test-repo-2
,test-repo-3
my-project-1
,my-project-2
,my-project-3
org-name/batch-test-1
,org-name/batch-test-2
# Create 1 repository (default)
./gh-bulk-repo.zsh
# Create 10 repositories with default prefix
./gh-bulk-repo.zsh 10
# Create 5 repositories with custom prefix
./gh-bulk-repo.zsh 5 my-test-project
# Create 10 repositories and clone them locally
./gh-bulk-repo.zsh 10 development-test --clone
# Create 100 repositories with cloning
./gh-bulk-repo.zsh 100 batch-repos --clone
# Create repositories in an organization
./gh-bulk-repo.zsh 50 my-org/test-project --clone
# Clean up organization repositories
./gh-bulk-repo.zsh 50 my-org/test-project --clean
# Delete 10 repositories with matching prefix
./gh-bulk-repo.zsh 10 test-repo --clean
# Clean up a large batch
./gh-bulk-repo.zsh 1000 load-test --clean
Flags can be placed anywhere in the command:
./gh-bulk-repo.zsh --clone 10 test-repo
./gh-bulk-repo.zsh 10 --clean test-repo
./gh-bulk-repo.zsh --clean 10 test-repo
🚀 Starting GitHub repository creation...
📊 Count: 10
🏷️ Prefix: test-repo
📥 Clone repos: true
⏱️ Started at: Fri Jun 13 13:25:43 AEST 2025
Creating repository: test-repo-1 ... ✅ SUCCESS
Creating repository: test-repo-2 ... ✅ SUCCESS
Creating repository: test-repo-3 ... ✅ SUCCESS
...
🎉 Repository creation completed!
📈 Summary:
✅ Successful: 10
❌ Failed: 0
📊 Total attempted: 10
🧹 Starting GitHub repository cleanup...
📊 Count: 10
🏷️ Prefix: test-repo
⏱️ Started at: Fri Jun 13 13:30:15 AEST 2025
Deleting repository: test-repo-1 ... ✅ DELETED
Deleting repository: test-repo-2 ... ✅ DELETED
...
🎉 Repository cleanup completed!
📈 Summary:
✅ Deleted: 10
❌ Failed: 0
📊 Total attempted: 10
The script includes comprehensive error handling:
- Invalid arguments: Clear error messages for incorrect usage
- Authentication issues: Checks for GitHub CLI authentication
- Permission errors: Validates required scopes for deletion
- API failures: Tracks and reports failed operations
- Rate limiting: Built-in delays to prevent API rate limit issues
- Create multiple test repositories for CI/CD testing
- Set up development environments with consistent naming
- Test GitHub integrations at scale
- Create repositories for workshop participants
- Set up classroom environments
- Demonstrate Git workflows with multiple repos
- Migrate or reorganize repository structures
- Create template repositories in bulk
- Clean up after large-scale testing
- Confirmation prompts: GitHub CLI handles confirmation for destructive operations
- Scope validation: Checks for required permissions before attempting operations
- Error isolation: Failed operations don't stop the entire batch
- Detailed reporting: Clear summary of successful and failed operations
- Rate limits: GitHub API has rate limits; the script includes delays but very large batches may still hit limits
- Repository limits: GitHub accounts have repository limits depending on plan type
- Network dependency: Requires stable internet connection for API calls
Feel free to submit issues, feature requests, or pull requests to improve this tool.
This script is provided as-is for educational and utility purposes.