This repository provides scripts to efficiently clone all repositories from a GitHub organization. Both Bash and Python scripts are included for flexibility. At successful run of the script you will get the cloned repositories inside 'cloned_repos' (configurable folder name). Use the config file to set your GITHUB_TOKEN to access private clones from the organization.
🆕 If the cloned repo exists, 🔄 it will sync the repos with the latest available version.
NOTE: Current setup is designed for Linux (or WSL2)/MACOs. Windows setup will be coming soon...
Follow these steps to clone all repositories from a GitHub organization:
Windows instructions to be added in next release !
- This tool uses make commands and python to handle virtuak environment and script runs. Please use the following bash commands if you does not have these tool installed in your system:
sudo apt install make
sudo apt install python3.12-venv- Clone this repository:
git clone https://github.com/DeltaE/clone_ORGANIZATION_repos.git
cd clone_ORGANIZATION_repos- Edit
config.env:DeltaE research lab folks can skip this step!
- Set
ORG_NAMEto your organization name (default:DeltaE). - Set
GITHUB_TOKENif you need access to private repositories or higher API rate limits.
- Create a Python virtual environment:
make venv- Install dependencies:
make install- Activate Virtual Environment
source .venv/bin/activate- Run the cloning script:
- The script will automatically clone new repositories or sync existing ones if the organization folder already exists
- A detailed summary report (
clone_summary.txt) is generated with operation history and results - Bash version:
OR
make run_bash
- Python version (uses the virtual environment):
make run_py
Find your cloned repositories:
- All repositories will be inside the folder defined by
MASTER_FOLDER(default:cloned_repos). - Repositories are organized by organization:
<MASTER_FOLDER>/<ORG_NAME>/ - Example:
cloned_repos/DeltaE/ - A
clone_summary.txtfile tracks all clone/sync operations with timestamps and results.
You can use a config.env file to set the organization name and API URL for cloning:
# config.env example
ORG_NAME=YourOrgName
API_URL=https://api.github.com/orgs
# Optional: GitHub token for private repos and higher API rate limits
GITHUB_TOKEN=your_token_hereORG_NAME: The default GitHub organization to clone from. If not set, defaults toDeltaE.API_URL: The base API URL for GitHub. Usually does not need to be changed.MASTER_FOLDER: The base folder where all cloned repositories will be stored. Defaults tocloned_repos.GITHUB_TOKEN: (Optional) GitHub token for authenticating API requests. Set this to access private repositories and increase API rate limits. If not set, only public repositories are accessible and rate limits are lower.
Note: If you provide an organization name as a command-line argument, it will override the value in config.env.
🆕 If the cloned repo exists, 🔄
make run_bashormake run_pywill sync the repos with the latest available version.
| Command / Script | Description |
|---|---|
make run_bash |
Clone or sync repositories from the organization (Bash script) |
make run_py |
Clone or sync repositories from the organization (Python script) |
python3 clone_org_repos.py <org> |
Clone/sync repositories from a custom organization using Python |
./clone_org_repos.bash <org> |
Clone/sync repositories from a custom organization using Bash |
-
NOTE: Remember to activate virtual environment, when you use this repo
source .venv/bin/activate
| Command / Script | Description |
|---|---|
export GITHUB_TOKEN=your_token_here |
Set token for private repos or higher API rate limits (optional) |
clone_org_repos.bash: Bash script for cloning repositories.clone_org_repos.py: Python script for cloning repositories.Makefile: Minimal makefile for easy usage..venv/: Python virtual environment directory.requirements.txt: Python dependencies for the script.
- All cloned repositories are stored in the folder defined by
MASTER_FOLDER(default:cloned_repos, configurable inconfig.env) - Repositories are organized by organization name directly under the master folder
- Smart behavior: Scripts automatically detect if repositories already exist and will sync them instead of re-cloning
cloned_repos/
├── DeltaE/
│ ├── clone_summary.txt # Operation history and results
│ ├── repo1/
│ ├── repo2/
│ └── repo3/
└── AnotherOrg/
├── clone_summary.txt
├── project1/
└── project2/
Each organization folder contains a clone_summary.txt file that tracks:
- Organization name and operation timestamps
- List of cloned/synced repositories with status
- Success/failure counts for each operation
- Complete operation history
- For Python script usage, ensure you have Python 3 installed.
- Customize
requirements.txtfor additional Python dependencies.
