This project provides a set of scripts to help you safely delete multiple GitHub repositories at once.
This action is irreversible. Deleting a GitHub repository permanently removes it, along with all its code, issues, pull requests, and settings. Please be absolutely certain before proceeding.
- GitHub CLI: You must have the official GitHub CLI installed.
- Authentication: You must be logged into your GitHub account through the CLI. If you haven't already, run:
gh auth login
First, you need to get a list of all your repositories.
- Make the
get_repo_list.shscript executable:chmod +x get_repo_list.sh
- Run the script:
./get_repo_list.sh
This will create a file named my_repos.txt containing a list of all your repositories in the owner/repo-name format.
Next, you need to specify which repositories you want to delete.
-
Open the
delete_repos.shfile in a text editor. -
Open the
my_repos.txtfile that was created in the previous step. -
Copy the full names of the repositories you want to delete from
my_repos.txtand paste them into therepos_to_deletearray insidedelete_repos.sh.Example:
# Before repos_to_delete=( "your-username/repo-to-delete-1" "your-username/repo-to-delete-2" ) # After repos_to_delete=( "JennySnyk/old-project-1" "JennySnyk/test-repo-4" "JennySnyk/another-one-to-delete" )
-
Save the
delete_repos.shfile.
This is the final step where the repositories are deleted.
- Make the
delete_repos.shscript executable:chmod +x delete_repos.sh
- Run the script:
./delete_repos.sh
The script will display the list of repositories you are about to delete and ask for a final confirmation. Type y and press Enter to proceed. The script will then delete each repository one by one.