-
-
Save KeyboardInterrupt/1f84267dc524cc81ff29db5be86276cf to your computer and use it in GitHub Desktop.
Mirror all my github repositories and gists
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
| #!/usr/bin/env python | |
| # See http://stackoverflow.com/questions/3581031/backup-mirror-github-repositories/13917251#13917251 | |
| import os | |
| import json | |
| import urllib | |
| import subprocess | |
| os.chdir(os.path.expanduser('~/github')) | |
| username = 'mgedmin' | |
| url = 'https://api.github.com/users/%s/repos?per_page=100' % username | |
| for repo in json.load(urllib.urlopen(url)): | |
| print "+", repo['full_name'] | |
| if os.path.exists(repo['name']): | |
| subprocess.call(['git', 'pull'], cwd=repo['name']) | |
| else: | |
| subprocess.call(['git', 'clone', repo['git_url']]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment