How to Download a Directory From GitHub (Without Cloning the Whole Repo)

GitHub makes it easy to clone an entire repository, but what if you only need one folder? Maybe it's a single component from a massive monorepo, or a specific set of config files you want to reuse. Downloading just a directory — not the whole project — is a common need, and GitHub doesn't make it immediately obvious how to do it.

Here's what's actually happening under the hood, and the methods available depending on your setup.

Why You Can't Just "Save" a GitHub Folder

GitHub displays directories as web pages, not downloadable file bundles. When you navigate to a subfolder in a repository, you're viewing a rendered HTML page — not a direct link to a zip file. That's why right-clicking and saving doesn't work the way it might on other file hosts.

To download a folder, you need to work around this using one of several approaches, each with its own trade-offs.

Method 1: Download via SVN (Subversion) Sparse Checkout

This is one of the most reliable command-line methods and doesn't require Git at all.

You'll need: Subversion installed (svn command available in terminal)

GitHub still supports the SVN protocol for repository access. You can use it to export a specific subdirectory without touching the rest of the repo.

The format is:

svn export https://github.com/[user]/[repo]/trunk/[folder-path] 

Note the key change: replace the /tree/main/ or /tree/master/ part of the GitHub URL with /trunk/. For example, if the GitHub URL is:

https://github.com/facebook/react/tree/main/packages/react-dom 

You'd run:

svn export https://github.com/facebook/react/trunk/packages/react-dom 

This downloads the folder contents directly to your current directory. No .git folder, no full repo history — just the files.

Variable to watch: SVN must be installed on your system. It's not bundled with most modern operating systems by default. On macOS, you can install it via Homebrew. On Windows, you'd need a separate installer. On Linux, it's usually available via your package manager.

Method 2: Sparse Checkout with Git

If you already have Git installed and want to keep things within the Git ecosystem, sparse checkout lets you clone a repo but only pull down specific directories.

git clone --filter=blob:none --sparse https://github.com/[user]/[repo].git cd [repo] git sparse-checkout set [folder-path] 

Breaking this down:

  • --filter=blob:none avoids downloading file contents up front
  • --sparse initializes sparse checkout mode
  • git sparse-checkout set specifies which directory to actually fetch

This method is more precise than a full clone but still initializes a local Git repository. That's useful if you might want to pull updates later, but overkill if you just need a one-time file grab.

Variable to watch: Sparse checkout behavior improved significantly in Git 2.25+. If you're running an older version, the commands and behavior may differ. Check your Git version with git --version.

Method 3: Third-Party Tools — DownGit and GitZip 📁

Several web tools exist specifically to solve this problem. You paste a GitHub folder URL, and the tool packages the contents into a downloadable zip.

Popular options include DownGit and GitZip. The general workflow is:

  1. Navigate to the folder on GitHub
  2. Copy the URL from your browser
  3. Paste it into the tool's input field
  4. Download the generated zip

These tools work by hitting the GitHub API behind the scenes. They're convenient for non-technical users or anyone who doesn't want to open a terminal.

Variables to watch:

  • These services are subject to GitHub API rate limits, especially for large folders or unauthenticated requests. You may hit errors on big downloads.
  • They depend on third-party uptime — if the service is down, the method fails.
  • Private repositories require authentication tokens, which not all tools support equally well.

Method 4: GitHub's Built-In Download (Whole Repo Only, With a Workaround)

GitHub's native "Download ZIP" button downloads the entire repository. For large repos, this is wasteful if you only need one folder.

However, if the repo is small enough, downloading the full zip and extracting just the folder you need is often the fastest path — no tools, no commands, no dependencies. It's worth considering before reaching for a more technical solution.

Comparing Your Options

MethodRequires TerminalGit NeededWorks on Private ReposBest For
SVN Export✅ Yes❌ No✅ With credentialsClean one-time folder download
Git Sparse Checkout✅ Yes✅ Yes✅ YesOngoing sync, large repos
DownGit / GitZip❌ No❌ No⚠️ LimitedQuick grabs, public repos
Full Repo ZIP + Extract❌ No❌ No✅ YesSmall repos, no setup

The Factors That Determine Which Method Works for You 🔧

No single method is universally best. What works depends on:

  • Your operating system — SVN availability and Git version vary across macOS, Windows, and Linux
  • Your technical comfort level — command-line tools are faster but have a steeper learning curve
  • Whether the repo is public or private — browser-based tools have limited private repo support
  • How often you need to do this — a one-time grab vs. a repeatable workflow calls for different approaches
  • The size of the folder — large directories stress API-based tools more than command-line methods
  • Your Git version — sparse checkout in particular behaves differently across versions

Understanding the mechanisms behind each method makes it easier to troubleshoot when something doesn't behave as expected. Rate limits, SVN availability, and Git versioning are the three most common friction points — and each one points to a different setup variable that only you can assess on your end. 🖥️