Skip to content

Instantly share code, notes, and snippets.

@ams0
Last active January 12, 2021 13:11
Show Gist options
  • Save ams0/39b7bd3d50a657c9026f36cf36a43170 to your computer and use it in GitHub Desktop.
Save ams0/39b7bd3d50a657c9026f36cf36a43170 to your computer and use it in GitHub Desktop.
Backup your Github account and start over

#Backup your github account

install the NPM package "repos"

npm install -g repos

get a list of all your repos

npx repos ams0 ams0-repos.json

get just the clone_url's

cat ams0-repos.json|  jq -r '.[].clone_url'| grep ams0 > repos.list

clone all your repos!

for repo in `cat repos.list`; do git clone $repo; done

Clean up your Github account

for repo in `cat repos.list| cut -c 20-| rev | cut -c5- | rev`; do gh api -X DELETE /repos/$repo >/dev/null 2>&1 ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment