File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import requests
2+ import os
3+
4+ # Replace with your GitHub username and personal access token
5+ username = "your-username"
6+ access_token = "your-access-token"
7+
8+ # Set the base URL for the GitHub API
9+ base_url = "https://api.github.com"
10+
11+ # Create a session with the access token to authenticate requests
12+ session = requests .Session ()
13+ session .auth = (username , access_token )
14+
15+ # Get the list of repositories for the authenticated user
16+ repositories_url = f"{ base_url } /user/repos"
17+ response = session .get (repositories_url )
18+ repositories = response .json ()
19+
20+ # Loop over the repositories and clone them to a local directory
21+ for repository in repositories :
22+ name = repository ["name" ]
23+ clone_url = repository ["clone_url" ]
24+ print (f"Cloning { name } from { clone_url } " )
25+ os .system (f"git clone { clone_url } " )
You can’t perform that action at this time.
0 commit comments