Skip to content

Instantly share code, notes, and snippets.

@fredmonroe
Created June 4, 2018 21:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredmonroe/14ab96b5fefc9fe465aa7cf92458f04e to your computer and use it in GitHub Desktop.
Save fredmonroe/14ab96b5fefc9fe465aa7cf92458f04e to your computer and use it in GitHub Desktop.
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