Skip to content

Instantly share code, notes, and snippets.

@Esonhugh
Created February 14, 2025 13:32
Show Gist options
  • Save Esonhugh/c059cd2c1914ea4b75be95a1795930ed to your computer and use it in GitHub Desktop.
Save Esonhugh/c059cd2c1914ea4b75be95a1795930ed to your computer and use it in GitHub Desktop.
clone EVERYTHING on git if you have a list
import sys
# usage: python cloner.py 1> cloner.sh 2> extract.sh
#
username = "user"
password = "pass_or_token"
domain = "github.com"
Prefix = f"git clone --mirror https://{username}:{password}@{domain}/"
REPOLIST_TXT= "repo_list" # filename contains lists of http/https urls on git
def get_git_url(line_arr):
return "/".join(line_arr[6:])
def get_dir(line_arr):
return "/".join(line_arr[6:])
PrefixClone = f"git clone "
ExtractedPrefix = "dec"
with open(REPOLIST_TXT, "r") as f:
line = "1"
count = 1
while line:
line = f.readline().strip()
line_arr = line.split("/")
git_url = get_git_url(line_arr)
dir = get_dir(line_arr)
print(f"echo current is {count} repo {git_url} clone to {dir}")
print(f"{Prefix}{git_url} {dir}")
print(f"echo current is {count} local mirror repo {dir} Extracted to {ExtractedPrefix}/{dir}", file=sys.stderr)
print(f"{PrefixClone} ./{dir} ./{ExtractedPrefix}/{dir}" ,file=sys.stderr)
count+=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment