Skip to main content

ghdir

Download a single folder from a GitHub repo, without cloning the whole thing.

Point it at a GitHub tree URL and it grabs just that folder, keeping the directory structure intact. You should probably use git clone if you're downloading an entire repo, but this tool works for that as well.

Install

Not on PyPI yet, so clone the repo and install from your local checkout:

git clone https://github.com/eko-071/ghdir.git
cd ghdir
uv tool install .

or with pip:

pip install .

Updating

Since it's installed from a local checkout, pull the latest changes and reinstall:

cd ghdir
git pull
uv tool install . --force

or with pip:

pip install . --force-reinstall

Needs Python 3.11+.

Usage

ghdir https://github.com/NVlabs/Eagle/tree/main/Embodied

This downloads everything under Embodied/ into a local Embodied/ folder.

A few flags if you need them:

  • -o, --output DIR — where to put the files (default: the folder's own name)
  • --branch NAME — use a different branch than the one in the URL
  • --dry-run — see the file count and total size without downloading anything
  • --workers N — number of concurrent downloads (default: 8)
  • --include GLOB — only download files matching this glob (repeatable)
  • --exclude GLOB — skip files matching this glob (repeatable)
  • --max-size SIZE — skip files larger than SIZE (e.g. 50M, 1.5G)
  • --force — re-download everything, even files that are already up to date
  • --version — print the installed version and exit

Some examples:

# whole repo, default branch
ghdir https://github.com/octo/hello

# a different branch than what's in the URL
ghdir https://github.com/octo/hello/tree/main/src --branch dev

# custom destination
ghdir https://github.com/octo/hello/tree/main/src -o ./vendor/hello-src

# just check what it would download
ghdir https://github.com/octo/hello/tree/main/src --dry-run

# only Python files, nothing over 50M
ghdir https://github.com/octo/hello/tree/main/src --include "*.py" --max-size 50M

Running it looks like this:

Found 132 files (1482974 bytes) in main/Embodied
Downloaded 132 files to Embodied

Already-up-to-date files are skipped on re-runs. Only missing or changed files are fetched. To force a fresh copy of everything, use --force:

Downloaded 0 files, skipped 132 already up to date, to Embodied

Shell completion

ghdir supports tab completion for bash, zsh, fish, and PowerShell:

ghdir --install-completion

This detects your shell and installs completion for flags (--branch, --include, etc.) and local directory paths for -o/--output. Restart your shell, or source your rc file, for it to take effect.

Developing

uv sync --extra dev           # install ghdir + dev deps
uv run pytest                 # unit tests, no network calls
uv run pytest -m integration  # live test against real GitHub repos
uv run ruff check src tests   # lint

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ghdir-0.1.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ghdir-0.1.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file ghdir-0.1.0.tar.gz.

File metadata

  • Download URL: ghdir-0.1.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for ghdir-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0e4e6e49ce5de6e340edbc011c61a32b064eb9338f3a3f2c235ecad981e9b560
MD5 d53cfc1c1f725138c5117b79e2a460da
BLAKE2b-256 dd2f6f78348f9a66a8b3f84521add063b7b5aa60a4694375e7e5384abf6bc0c4

See more details on using hashes here.

File details

Details for the file ghdir-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ghdir-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for ghdir-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aaabacb0650a4b68288e631c55b9eeca22cf0d201760ba746f61b7fe1bd648bf
MD5 b494a2bd67d5bcc792f6c5d60157f543
BLAKE2b-256 23a7de6b367855401e6c86436e68348db837095a3e812db567030ba395557ad7

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.0

2 files

This release

0.1.0 This release

2 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