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
pip install ghdir
or with uv:
uv tool install ghdir
Needs Python 3.11+.
From source
git clone https://github.com/eko-071/ghdir.git
cd ghdir
uv tool install .
or with pip:
pip install .
Updating
pip install --upgrade ghdir
or:
uv tool upgrade ghdir
If you installed from a local checkout instead, pull and reinstall:
cd ghdir
git pull
uv tool install . --force
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 thanSIZE(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
Authentication
By default ghdir hits the GitHub API anonymously (60 requests/hour) and cannot download from private repositories. Storing a token unlocks private repos and raises the limit to 5000 requests/hour:
ghdir auth login # prompts for a token, or pass --token TOKEN inline
ghdir auth status # show who you're logged in as
ghdir auth logout # remove the stored token
Tokens are saved to ~/.config/ghdir/token (mode 0600). For CI or
scripted use, set the GHDIR_TOKEN environment variable instead — it
takes precedence over the stored file and needs no interactive prompt.
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
Metadata
Release files for ghdir 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ghdir-0.2.0.tar.gz | 20.5 kB | Without provenance | Details for ghdir-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ghdir-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for ghdir-0.2.0-py3-none-any.whl |
Total release size: 36.1 kB
Release files / ghdir-0.2.0.tar.gz
| Download URL | ghdir-0.2.0.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
903b0e4bc804882c09c00bd056da601473ff73573ca770c63a0fa97b428c9cec
|
|
BLAKE2b-256 checksum How to use checksums |
f2e8a7a5dbd4067c7bb9af46d9a6d6d03a4ee75b2d29a515513833aa2fd6508b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / ghdir-0.2.0-py3-none-any.whl
| Download URL | ghdir-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce8159bdc5b2668d005f84bdaac5bccc2e633be15f17d7f8155d3e3636fc1c62
|
|
BLAKE2b-256 checksum How to use checksums |
f0a495110bab36e3a9d8cdf87e55a25ff266a0a10735cfbddf21a83f8a898083
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for ghdir 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.