Skip to content

Instantly share code, notes, and snippets.

@shajeen
Last active March 8, 2024 09:20
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save shajeen/081d921d84058e427d1cdcbe4577996f to your computer and use it in GitHub Desktop.
Save shajeen/081d921d84058e427d1cdcbe4577996f 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