Skip to content

Instantly share code, notes, and snippets.

@ericgrosse
Created January 30, 2023 15:45
Show Gist options
  • Save ericgrosse/81056d3e2d1b8fed670bed3af6038ab2 to your computer and use it in GitHub Desktop.
Save ericgrosse/81056d3e2d1b8fed670bed3af6038ab2 to your computer and use it in GitHub Desktop.
Clone all your repositories at once with a simple python script
// Note: You need to plug in your github username, as well as a github personal access token found through Settings -> Developer Settings -> Personal Access Tokens -> Tokens (classic).
import requests
import os
# Your Github username
username = "<github_username>"
# API endpoint to get a list of all repositories
url = f"https://api.github.com/users/{username}/repos"
# Send a GET request to the API endpoint
response = requests.get(url, auth=(username, "<github personal access token>"))
# Check if the request was successful
if response.status_code == 200:
# Get the list of repositories
repositories = response.json()
for repo in repositories:
repo_name = repo["name"]
clone_url = repo["clone_url"]
# Clone the repository
os.system(f"git clone {clone_url} {repo_name}")
else:
print(f"Request failed with status code: {response.status_code}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment