A simple and efficient Node.js script to delete multiple GitHub repositories at once while ensuring that specified repositories are protected from deletion.
- Fetches all repositories from your GitHub account (handles pagination).
- Excludes specific repositories from deletion using an escape list.
- Deletes repositories sequentially to avoid hitting GitHub API rate limits.
- Provides clear logs on which repositories were deleted and which failed.
- Node.js (v14 or later)
- A GitHub Personal Access Token with
repoanddelete_repopermissions.
git clone https://github.com/emirxmertoglu/gh-repo-cleaner.git
cd gh-repo-cleanerSince this script only uses Axios, you can install it via:
yarn installOpen index.js and replace the placeholders:
const GITHUB_ACCESS_TOKEN = "your_personal_access_token";
const USERNAME = "your_github_username";
const ESCAPE_LIST = ["repo1", "repo2", "repo3"];node index.js- This action is irreversible! Double-check the
ESCAPE_LISTbefore running the script. - GitHub imposes rate limits on API requests. If you have too many repositories, you might hit these limits.
Feel free to fork this repository and submit pull requests. Any contributions, whether fixing bugs, optimizing code, or adding features, are welcome!
This project is licensed under the MIT License.