Skip to content

anesask/github_repo_bulk_manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Repo Bulk Manager

A simple bash script to bulk archive and delete GitHub repositories using the GitHub CLI.

Features

  • List all your repositories with status (private/archived)
  • Export repository list to a file
  • Bulk archive repositories (private + archive OR public + archive)
  • Bulk delete repositories
  • Filter repositories (public only, non-archived only)
  • Interactive menu interface
  • Safety confirmations before destructive actions
  • Automatic line number stripping from files
  • File formatting utility to clean up repository lists
  • Cross-platform support (Linux, macOS, Windows)

Prerequisites

  • GitHub CLI (gh) - Installation Guide
  • Bash - Available on Linux, macOS, Git Bash (Windows), WSL

Installation

1. Install GitHub CLI

Windows:

winget install --id GitHub.cli

macOS:

brew install gh

Linux (Debian/Ubuntu):

curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh

2. Authenticate with GitHub

gh auth login

Important: For repository deletion, refresh your authentication with the delete_repo scope:

gh auth refresh -h github.com -s delete_repo

3. Download the Script

# Clone this repository
git clone https://github.com/yourusername/github-repo-bulk-manager.git
cd github-repo-bulk-manager

# Make the script executable
chmod +x manage-repos.sh

Usage

Run the Script

./manage-repos.sh

Menu Options

  1. List all repositories - View all repos with their status
  2. Export repository list to file - Save repo names to a text file
  3. Archive repositories (private + archive) - Make repos private AND archive them
  4. Archive repositories (keep public + archive) - Archive repos while keeping them public
  5. Delete repositories from file - Permanently delete repos
  6. Quick filter: Show only public repos - List public repositories
  7. Quick filter: Show only non-archived repos - List active repos
  8. Exit - Close the script

Typical Workflow

To Archive Multiple Repos:

# 1. Run the script
./manage-repos.sh

# 2. Export repos to a file (option 2)
# Enter filename: repos-to-archive.txt

# 3. Edit the file to keep only repos you want to archive
nano repos-to-archive.txt  # or use your preferred editor

# 4. Run the script again and select option 3
# Enter the filename when prompted

# 5. Confirm the action

To Delete Multiple Repos:

# 1. Export repos to a file
./manage-repos.sh
# Choose option 2

# 2. Edit the file to keep only repos you want to DELETE
nano repos-to-delete.txt

# 3. Run the script and select option 4
# You must type 'DELETE' to confirm

# 4. Repos will be permanently deleted

File Format

The script accepts repository names in the following formats:

username/repo-name
username/another-repo

It also automatically handles files with line numbers:

1→username/repo-name
2→username/another-repo

Comments and empty lines are ignored:

# This is a comment
username/repo-name

username/another-repo
# Another comment

Formatting Files

If you want to clean up a file (remove line numbers, empty lines, comments):

# Make the format script executable
chmod +x format-repos-file.sh

# Clean up in place
./format-repos-file.sh repos.txt

# Or create a new clean file
./format-repos-file.sh repos.txt repos-clean.txt

This prevents having duplicate files like delete.txt and delete-clean.txt.

Safety Features

  • Authentication check - Verifies GitHub CLI is authenticated before running
  • Confirmation prompts - Asks for confirmation before destructive actions
  • Delete protection - Requires typing "DELETE" to confirm deletion
  • Progress feedback - Shows real-time status for each repository
  • Error handling - Continues processing if individual repos fail

Examples

Archive all public repositories

./manage-repos.sh
# Choose option 5 to list public repos
# Copy the output to a file
# Choose option 3 to archive them

Delete old test repositories

# Export all repos
./manage-repos.sh
# Choose option 2

# Edit the file and keep only test repos
grep -i "test" repos-list.txt > test-repos.txt

# Delete them
./manage-repos.sh
# Choose option 4 and enter test-repos.txt

Troubleshooting

"gh: command not found"

  • Restart your terminal after installing GitHub CLI
  • On Windows with Git Bash, you may need to add the path manually:
    export PATH="$PATH:/c/Program Files/GitHub CLI"

"Failed to delete" errors

  • Ensure you have the delete_repo scope:
    gh auth refresh -h github.com -s delete_repo

"Failed to archive" errors

  • Check if you have permission (owner/admin access required)
  • Some organizations may restrict archiving

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - See LICENSE file for details

Disclaimer

USE AT YOUR OWN RISK

  • Repository deletion is permanent and cannot be undone
  • Always review the list of repositories before confirming
  • Consider backing up important repositories before deletion
  • The author is not responsible for any data loss

Author

Created by @anesask to simplify bulk repository management on GitHub.

About

Interactive CLI tool to bulk manage GitHub repositories - archive (public/private) and delete with safety confirmations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages