Created
June 4, 2018 21:28
-
-
Save fredmonroe/14ab96b5fefc9fe465aa7cf92458f04e to your computer and use it in GitHub Desktop.
This file contains 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
from github import Github | |
from pathlib import Path | |
from git import Repo | |
skip = ['UnrealEngine'] # a really big repo i want to skip | |
token = "xxxxxxxxxxx" # github personal access token | |
g = Github(token) | |
dest = Path('/repos/go/here') # save my cloned repos here | |
dest.mkdir(parents=True, exist_ok=True) | |
user = g.get_user() | |
for repo in user.get_repos(): | |
rpath = dest/repo.name | |
if repo.fork or repo.name in skip or rpath.exists(): | |
print('skip: %s' % repo.name) | |
else: | |
try: | |
repo_url = repo.clone_url.replace('https://github.com', 'https://x-access-token:%s@github.com' % token ) | |
print('pull: %s' % repo.name) | |
Repo.clone_from(repo_url, rpath) | |
except: | |
print('error: %s' % repo.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment