Skip to content

Instantly share code, notes, and snippets.

@gabmontes
Last active December 3, 2023 08:39
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save gabmontes/b14a33fdd7081939b932 to your computer and use it in GitHub Desktop.
Save gabmontes/b14a33fdd7081939b932 to your computer and use it in GitHub Desktop.
Delete all your gists
var async = require('async');
var GitHubApi = require('github');
var github = new GitHubApi({
version: '3.0.0',
protocol: 'https'
});
github.authenticate({
type: 'basic',
username: 'user',
password: 'pass'
});
async.waterfall([
function (callback) {
github.gists.getAll({}, callback);
},
function (gists, callback) {
// filter gists by properties as needed
async.each(gists, function (gist, callback) {
github.gists.delete({
id: gist.id
}, callback);
}, callback);
}
], function (err) {
if (err) {
console.log('Execution failed: %s', err.message);
process.exit(1);
}
console.log('Done!');
process.exit(0);
});
@hmpandey
Copy link

please can you provide little much document regarding this

@gabmontes
Copy link
Author

@hmpandey it just iterates over all your gists and deletes one by one using the GitHub API. As simple as that!!

@mikedevita
Copy link

mikedevita commented May 25, 2017

FYI i had to modify this a bit, change line 21 to be gists.data, and then it worked for me. I also noticed it only deletes ~50 at a time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment