How to Use Git Sparse-Checkout to Download One GitHub Folder
Git sparse-checkout is a built-in git feature (2.25+) that clones a repository but only materializes the subfolder you ask for in your working directory. Unlike a one-time ZIP snapshot, what you get is a real, fully-functional git repository — you can commit, branch, and git pull to stay in sync with the remote, scoped to just that folder.
The modern workflow combines a partial clone with cone-mode sparse-checkout: five commands, run once, and you have a working directory containing only the folder you need, backed by a real git history you can keep pulling from.
-
Partial-clone the repo without checking out files
--filter=blob:nonetells git to skip downloading file contents up front (a "partial clone"), and--no-checkoutskips populating your working directory until sparse-checkout is configured — otherwise git would briefly check out every file before you get a chance to scope it down.git clone --filter=blob:none --no-checkout https://github.com/owner/repo.git -
Move into the new repo directory
Every command from here runs inside the cloned repo.
cd repo -
Turn on cone-mode sparse-checkout
--coneenables the modern, faster pattern-matching mode. It's optimized for whole-directory inclusion (as opposed to the legacy full-pattern mode, which supports arbitrary gitignore-style globs but is slower and easier to misconfigure).git sparse-checkout init --cone -
Set the one folder you want
This tells git which path to materialize. You can pass multiple paths here, or call
setagain later to change scope — it replaces the previous selection rather than adding to it.git sparse-checkout set path/to/folder -
Check out the branch to populate the folder
This is the step that actually writes files to disk — only the folder(s) set above will appear in your working directory, even though the full ref history is present.
git checkout main
Sparse-checkout vs. a one-time download
Sparse-checkout and a download tool solve the same surface problem — "I only want one folder" — but they trade off differently, and which one is better depends on what you're about to do with the files.
Sparse-checkout gives you a live, git pull-able repository scoped to one folder. That's the right call if you plan to keep working against that folder over time: pull updates, commit changes, open PRs, all with normal git tooling. The cost is that it requires git installed locally and enough command-line comfort to run five commands correctly in order — get the sequence wrong and you can end up with a full checkout anyway.
A tool like GitHubFolder (or the SVN export trick) gives you a one-time snapshot instead: paste a URL, see a visual file-tree preview of exactly what's in the folder, pick what you want, and download a ZIP — zero setup, no git required, nothing installed. For a one-off need — grabbing an example project, a single component, a config directory — that's faster and requires no local tooling at all. It's simply not the right tool if you need ongoing sync back to the remote.
Sparse-checkout isn't always "light"
Partial clone filtering (--filter=blob:none) skips file contents you haven't checked out yet, but it still downloads the full commit history's metadata — every commit, tree, and ref. On a very large or very old repository, that metadata alone can be a meaningful download, so sparse-checkout isn't automatically lighter-weight than a one-time snapshot. Choose based on whether you need ongoing sync, not just on folder size.