Skip to content

Commit 9a68dbf

Browse files
Create downloading_all_repos.py
1 parent 84798f8 commit 9a68dbf

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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}")

0 commit comments

Comments
 (0)