DEV Community

Cover image for How to clone all GitHub repos of multiple users at once?
Shoban Chiddarth
Shoban Chiddarth

Posted on Edited on Originally published at shobanchiddarth.hashnode.dev

How to clone all GitHub repos of multiple users at once?

Repo Link

This script helps you clone all repositories of a given list of GitHub users (including organizations) at once, instead of cloning them manually one by one.

I built it after running into the need to archive and collect repositories from multiple accounts efficiently. The goal was simple: automate bulk cloning in a clean, repeatable way.


What It Does

  • Accepts multiple GitHub usernames
  • Fetches all accessible repositories via the GitHub API
  • Clones them into a structured local directory
  • Supports shallow clone (--depth 1) or full history
  • Skips repositories that are inaccessible or already cloned

Each user gets their own folder inside the target directory.


Requirements

  • Python 3.12+
  • git installed and available in PATH
  • A GitHub Personal Access Token with read access to repository contents

Setup

  1. Generate a Personal Access Token:

    • Go to GitHub → Settings → Developer settings → Personal access tokens
    • Create a token with repository read access
  2. Copy sample.env to .env

  3. Replace the placeholder token value with your actual token

  4. Install dependencies:

   pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

Usage

Run:

python github-main.py
Enter fullscreen mode Exit fullscreen mode

You’ll be prompted for:

  • A space-separated list of GitHub usernames
  • A target directory (default: mass_clone_output)
  • Clone depth (None for full history or 1 for latest commit only)

The script validates usernames, fetches repositories, and clones them sequentially with live git clone output shown in the terminal.


Repository

Top comments (0)