A high-performance CLI that lets you download individual folders, branches, or entire repositories from GitHub without cloning the whole repo. Written in Python with a focus on speed, reliability, and an excellent terminal experience.
- Overview
- Key Features
- Installation
- Quick Start
- Configuration
- Usage Recipes
- CLI Reference
- Advanced Topics
- Error Handling
- Contributing
- License
gh-folder-download helps you grab just the parts of a repo you needโperfect for CI pipelines, config backups, documentation syncs, or one-off code reviewsโwhile saving bandwidth and GitHub API quota.
- ๐ Fast & Parallel โ asyncio-powered downloads with configurable concurrency.
- ๐ Beautiful Progress Bars โ per-file and overall progress, ETA, speed, and rich colors.
- ๐พ Intelligent Cache โ SHA-based cache prevents re-downloading unchanged files.
- ๐ Granular Filtering โ include or exclude by extension, glob pattern, size, or binary type.
- ๐๏ธ Smart Rate Limiting โ adaptive GitHub API usage with optional bypass.
- โ๏ธ Flexible Config โ YAML config file, env vars, or CLI flags (with clear precedence).
- โ Integrity Checks โ optional size & hash verification after download.
- ๐ Auto Retry โ exponential back-off for network, server, or rate-limit hiccups.
Run instantly with uv (no install):
uvx gh-folder-download --url https://github.com/leynier/gh-folder-downloadOr install from PyPI:
# Pick your preferred manager
pip install gh-folder-download
uv add gh-folder-download
poetry add gh-folder-download
conda install gh-folder-downloadDownload a folder from the main branch into the current directory:
gh-folder-download --url https://github.com/user/repo/tree/main/path/to/folderUse a token (private repo) and quiet mode:
gh-folder-download --url https://github.com/org/private-repo \
--token $GITHUB_TOKEN \
--quietgh-folder-download reads settings in this order (later overrides earlier):
- Built-in defaults
- YAML config file (auto or
--config-file) - Environment variables (
GH_FOLDER_DOWNLOAD_*) - CLI flags
| Priority | Path |
|---|---|
| 1 | ./gh-folder-download.yaml |
| 2 | ~/.config/gh-folder-download/gh-folder-download.yaml |
| 3 | ~/.gh-folder-download.yaml |
Generate a starter file:
gh-folder-download --create-config# GitHub authentication
github_token: "your_github_token_here"
# Download settings
download:
max_concurrent: 5
timeout: 30
chunk_size: 8192
max_retries: 3
retry_delay: 1.0
verify_integrity: true
parallel_downloads: true
# Cache settings
cache:
enabled: true
max_size_gb: 5.0
max_age_days: 30
auto_cleanup: true
# Rate limiting
rate_limit:
enabled: true
buffer: 100
aggressive_mode: false
# File filters
filters:
include_extensions: [".py", ".js", ".md"]
exclude_extensions: [".log", ".tmp"]
exclude_binary: false
exclude_large_files: false
respect_gitignore: false
# Paths
paths:
default_output: "."
create_subdirs: true
preserve_structure: true
# UI
ui:
show_progress: true
verbosity: "INFO"
use_colors: true
quiet_mode: falseexport GH_FOLDER_DOWNLOAD_GITHUB_TOKEN="your_token"
export GH_FOLDER_DOWNLOAD_MAX_CONCURRENT=10
export GH_FOLDER_DOWNLOAD_SHOW_PROGRESS=falsegh-folder-download --url https://github.com/user/repogh-folder-download --url https://github.com/user/repo \
--include-extensions .py .md \
--exclude-patterns "**/test/**" "**/*.pyc"| Profile | Description | Recommended Flags |
|---|---|---|
| Fastest | For max speed | --parallel-downloads --max-concurrent 20 --no-use-cache --disable-rate-limiting |
| Balanced | Good default | --parallel-downloads --max-concurrent 8 --use-cache |
| Reliable | Focus on correctness | --max-retries 8 --retry-delay 2 --verify-integrity |
Run gh-folder-download --help for the full list. Common options include:
--url(required): GitHub repo or folder URL--output: Target directory--token: GitHub personal token--include-extensions,--exclude-patterns: File filters--parallel-downloads,--max-concurrent: Speed tuning--show-progress,--quiet,--verbose: Output control
- Progress Bars: Enable/disable with
--show-progress - Caching: SHA-based, inspect with
--cache-stats - Rate Limiting: Adaptive, or override with
--disable-rate-limiting - File Validation: Use
--verify-integrity
Handles:
- Network issues (timeouts, DNS, etc.)
- Permission and token errors
- Invalid GitHub URLs or paths
- Disk I/O problems
Use --verbose or --log-file for deeper diagnostics.
PRs welcome! See CONTRIBUTING.md.
MIT License. See LICENSE.