Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save applicato/3106b7bdb75d50854fa1cc406c0d86c0 to your computer and use it in GitHub Desktop.
Save applicato/3106b7bdb75d50854fa1cc406c0d86c0 to your computer and use it in GitHub Desktop.
Code to download all stared repo
from github import Github
from pygit2 import clone_repository
import random
import string
import json
import os
path = "/home/shajeen/Documents/git_stared/"
g = Github("git personal access token")
starred = []
total = g.get_user().get_starred().totalCount
print("Total repo count: " + str(total))
for repo in g.get_user().get_starred():
starred.append((repo.name, repo.clone_url))
num = 1
for repo in starred:
#clone_repository(repo, path)
name, url = repo
print("["+str(num)+"/"+str(total)+"] "+"cloning repo: " + name)
clone_path = path+name
if os.path.exists(clone_path):
clone_path = clone_path+"_"+''.join(random.choice(string.ascii_letters) for i in range(8))
print("on: " + clone_path)
os.mkdir(clone_path)
clone_repository(url, clone_path)
print("done.")
num = num+1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment