Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clone all my gists automatically (gist backup?)
#!/usr/bin/env python
# Git clone all my gists
import json
import urllib
from subprocess import call
from urllib import urlopen
import os
USER = os.environ['USER']
u = urlopen('https://gist.github.com/api/v1/json/gists/' + USER)
gists = json.load(u)['gists']
for gist in gists:
call(['git', 'clone', 'git://gist.github.com/' + gist['repo'] + '.git'])
@endolith

This comment has been minimized.

Copy link

commented Jun 5, 2016

This URL doesn't exist anymore

@mintern

This comment has been minimized.

Copy link

commented Jul 6, 2016

Thanks a lot! I got it to work with a few minor tweaks:

#!/usr/bin/env python
# Git clone all my gists to current directory
# From https://gist.github.com/joneskoo/1480022

import json
import urllib
from subprocess import call
from urllib import urlopen
import os
USER = os.environ['USER'] # or edit as appropriate

u = urlopen("https://api.github.com/users/%s/gists" % USER)
gists = json.load(u)

for gist in gists:
    call(['git', 'clone', gist['git_pull_url']])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.