gh-folder-download downloads a repository or one of its folders without cloning its Git history. It provides
parallel transfers, transactional replacement, Git blob integrity checks, content-addressed caching, filters, retries,
rate-limit awareness, and YAML/environment configuration.
Python 3.13 or newer is required.
uvx gh-folder-download --url https://github.com/leynier/gh-folder-download
# or
pip install gh-folder-download--output is always a parent directory:
Repository URL Destination
https://github.com/user/project OUTPUT/project
https://github.com/user/project/tree/main/docs/guides
OUTPUT/docs/guides
An existing calculated destination is rejected unless --force is supplied. Forced downloads are prepared and
verified in a sibling staging directory first; the existing destination is replaced only after every selected file
succeeds. --force never removes the directory passed directly to --output.
# Download a complete repository into ./project
gh-folder-download --url https://github.com/user/project
# Download one folder
gh-folder-download \
--url https://github.com/user/project/tree/main/docs \
--output ./downloads
# Use an unambiguous branch name containing slashes
gh-folder-download \
--url https://github.com/user/project \
--ref feature/new-docs \
--path docs
# Replace a previous destination and reuse verified cached blobs
gh-folder-download --url https://github.com/user/project --force --use-cache
# Download only Python files that are not ignored by the repository
gh-folder-download \
--url https://github.com/user/project \
--include-extensions .py \
--respect-gitignoreRun gh-folder-download --help for every option. Useful standalone cache commands are:
gh-folder-download --cache-stats
gh-folder-download --clear-cacheConfiguration precedence is:
- Built-in defaults
- The first discovered YAML file, or
--config-file GH_FOLDER_DOWNLOAD_*environment variables- Explicit CLI options
Files are discovered in this order:
./gh-folder-download.yaml~/.config/gh-folder-download/gh-folder-download.yaml~/.gh-folder-download.yaml
Generate a documented example with:
gh-folder-download --create-configExample:
download:
max_concurrent: 5
timeout: 30
chunk_size: 8192
max_retries: 3
retry_delay: 1.0
verify_integrity: true
parallel_downloads: true
cache:
enabled: true
max_size_gb: 5.0
max_age_days: 30
auto_cleanup: true
rate_limit:
enabled: true
buffer: 100
filters:
include_extensions: [".py", ".md"]
exclude_patterns: ["**/generated/**"]
exclude_binary: false
exclude_large_files: false
respect_gitignore: true
paths:
default_output: "."
ui:
show_progress: true
verbosity: "INFO"
use_colors: true
quiet_mode: falseSupported environment variables include:
export GH_FOLDER_DOWNLOAD_GITHUB_TOKEN="github_pat_..."
export GH_FOLDER_DOWNLOAD_MAX_CONCURRENT=10
export GH_FOLDER_DOWNLOAD_SHOW_PROGRESS=falseGITHUB_TOKEN is also accepted as a fallback when no CLI/config namespaced token is set.
0: traversal and installation completed, including a valid filter that selected zero files.1: remote, download, integrity, cache, or destination failure.2: invalid CLI input, URL, path, or configuration.
Downloads use temporary .part files, retry transient HTTP failures with exponential backoff, verify the Git blob SHA
when integrity checks are enabled, and install the staged directory only after complete success. Expected failures are
shown without a traceback; use --verbose for diagnostic tracebacks.
make check # lint, format check, types, offline tests, and package build
make integration # network tests against GitHubThe offline suite enforces 100% line coverage for the gh_folder_download package. Network tests use pytest temporary
directories and are excluded from the default test run. See
contributing.md for contribution guidelines.
MIT. See license.