repos.txtcontains a list of repository names in{UserName}/{RepoName}format, e.g.IanZhao/to-be-deleted. use this file to track all repositories you want to delete.- Open
fetchSaveRepo.jsand update url with your github username. - you need
node-fetchto fetch contents, just do anpm initwith default settings and runnpm install node-fetch. - run
node fetchSaveRepo.js - Generate a Authorization Token for repo delete access token
- Copy the token and put in in place
TOKEN_HEREindeleteRepos.sh - If you certain, run
./deleteRepos.sh.
Created
April 11, 2018 22:16
-
-
Save randomradio/fb567fecd32e8fdce61602a311c0d19f to your computer and use it in GitHub Desktop.
batch remove github repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while read r; do | |
| echo "https://api.github.com/repos/$r" | |
| curl -XDELETE -H 'Authorization: token TOKEN_HERE' "https://api.github.com/repos/$r"; | |
| done < repos.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fetch = require('node-fetch'); | |
| const fs = require('fs'); | |
| const path = 'repos.txt'; | |
| const repoUrl = 'https://api.github.com/users/{username}/repos?per_page=200'; | |
| const logger = fs.createWriteStream(path, { | |
| flags: 'a', | |
| }); | |
| const fetchRepos = (url = 'https://api.github.com/users/{username}/repos?per_page=200') => { | |
| fetch(url) | |
| .then(reply => reply.json()) | |
| .then((results) => { | |
| results.map((repo) => { | |
| console.log(repo.name); | |
| const name = `${repo.full_name}\n`; | |
| logger.write(name); | |
| return true; | |
| }); | |
| }) | |
| .then(() => logger.end()) | |
| .catch(err => console.log(err)); | |
| }; | |
| fetchRepos(repoUrl); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # IanZhao/repo-to-delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment