Skip to main content

GitHub Folder Downloader

License: MIT PyPI

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.

Installation

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

Destination behavior

--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.

Usage

# 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-gitignore

Run gh-folder-download --help for every option. Useful standalone cache commands are:

gh-folder-download --cache-stats
gh-folder-download --clear-cache

Configuration

Configuration precedence is:

  1. Built-in defaults
  2. The first discovered YAML file, or --config-file
  3. GH_FOLDER_DOWNLOAD_* environment variables
  4. Explicit CLI options

Files are discovered in this order:

  1. ./gh-folder-download.yaml
  2. ~/.config/gh-folder-download/gh-folder-download.yaml
  3. ~/.gh-folder-download.yaml

Generate a documented example with:

gh-folder-download --create-config

Example:

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: false

Supported environment variables include:

export GH_FOLDER_DOWNLOAD_GITHUB_TOKEN="github_pat_..."
export GH_FOLDER_DOWNLOAD_MAX_CONCURRENT=10
export GH_FOLDER_DOWNLOAD_SHOW_PROGRESS=false

GITHUB_TOKEN is also accepted as a fallback when no CLI/config namespaced token is set.

Reliability and exit codes

  • 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.

Development

make check        # lint, format check, types, offline tests, and package build
make integration  # network tests against GitHub

The 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.

License

MIT. See license.

Release files for gh-folder-download 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gh-folder-download 1.0.1
File Size Uploaded
gh_folder_download-1.0.1.tar.gz 141.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gh-folder-download 1.0.1
File Interpreter ABI Platform
gh_folder_download-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 186.2 kB

Release files / gh_folder_download-1.0.1.tar.gz

Download URL gh_folder_download-1.0.1.tar.gz
Size 141.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7d1678cdb48efa5a6727d132b05725b9f7bf4bc508d586a60ae202cd6c0e5aa1
BLAKE2b-256 checksum
How to use checksums
9b757fba8697fb7e0f09f532e8c0d583edeb8becab1c960920927443cd2edb3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gh_folder_download-1.0.1-py3-none-any.whl

Download URL gh_folder_download-1.0.1-py3-none-any.whl
Size 44.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91161f39ce839d085d1d2b37a8a1051dab106ac65de6e64323a499bd94f6d05e
BLAKE2b-256 checksum
How to use checksums
eedfddf4d3c974be65ccc4a7a965e76f842dbde542f18ea0ccf6d9b6fa7e7553
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page