Download a single folder or directory from a GitHub repo

How can I download only a specific folder or directory from a remote Git repo hosted on GitHub?

Say the example GitHub repo lives here:

  • Why remote git server should have --bare
  • exclude only js files from gitignore
  • Git does not detect repository
  • Git commit doesn't show on repository when a tag is moved towards it on push
  • Git: how to go back before merge
  • Why does checking out a git tag bring the wrong version of the code?

    Its directory structure:


    I want to download only the foo folder and not clone the whole Test project.

  • Continuous integration and continuous delivery with git-flow
  • Ruby gem error while trying to login to openshift via terminal
  • What is the equivalent of hg up -C in git
  • What can FishEye do that we cannot get from other tools for a git repository?
  • Git Submodules - Updating and Commiting changes
  • Authorization for on Android
  • 21 Solutions collect form web for “Download a single folder or directory from a GitHub repo”

    Update Sep. 2016: there are a few tools created by the community that can do this for you:

    • GitZip (Credits to Kino – upvote his answer right here!)

    • DownGit (Credits to Minhas Kamal – upvote his answer right here!)

    Git doesn’t support this, but Github does via SVN. If you checkout your code with subversion, Github will essentially convert the repo from git to subversion on the backend, then serve up the requested directory.

    Here’s how you can use this feature to download a specific folder. I’ll use the popular javascript library lodash as an example.

    1. Get the repo URL. First, copy the URL of the Github repo to your clipboard.
      github repo URL example

    2. Modify the URL for subversion. I want to download the folder at /docs from the master branch, so I will append trunk/docs. Full URL is now See my note below for a more in-depth explanation of why we must use this URL format.

    3. Download the folder. Go to the command line and grab the folder with SVN.

      svn checkout

    You might not see any activity immediately because Github takes up to 30 seconds to convert larger repositories, so be patient.

    Full URL format explanation:

    • If you’re interested in master branch, use trunk instead. So the full path is trunk/foldername
    • If you’re interested in foo branch, use branches/branchname instead. The
      full path looks like branches/branchname/foldername
    • Protip: You can use svn ls to see available tags and branches before downloading if you wish

    That’s all! Github supports more subversion features as well, including support for committing and pushing changes.

    Two options for this feature:

    Option 1: Chrome Extension

    Extension: GitZip for github


    1. In any GitHub public repos page.
    2. Just double click on the items you need.
    3. Click download button at bottom-right.
    4. See the progress dashboard and wait for browser trigger download.
    5. Get the ZIP file.

    Get Token:

    1. Click GitZip Extension icon on your browser.
    2. Click “Get Token” link.
    3. Authorize GitZip permission on Github auth page.
    4. Back to repo page of the beginning.
    5. Continue to use.

    Option 2: Github gh-page by using GitHub API, and JSZip, FileSaver.js libraries.

    Step1: Input github url to the field at the top-right.
    Step2: Press enter or click download for download zip directly or click search for view the list of sub-folders and files.
    Step3: Click “Download Zip File” or “Get File” button to get files.

    In most cases, it works fine, except that the folder contains more than 1,000 files, because of the Github Trees API limitation. (refers to Github API#Contents)

    And it also can support private/public repos and upgrade the rate limit, if you have GitHub account and use “get token” link in this site.

    Tip: token sync

    If you are a gitzip gh-page user, and also got token on the site; Now, you can install the GitZip for github Chrome Extension and visit gh-page site again after installed, it would sync token automatically.

    Now you can DIRECTLY DOWNLOAD or create DOWNLOAD LINK for any GitHub public directory from HERE!

    I wished to do similar thing as the question asker, for one of my projects. I not only wanted to download the whole directory, but also create a direct download link for that. But I found nothing that could meet my need. So, I have created a project in GitHub- DownGit, for solving the problem.

    Go to DownGit, enter your GitHub directory url, and download. Here is a simple demonstration-

    enter image description here

    I believe it will serve as a great help.

    If you have svn, you can use svn export to do this:

    svn export

    Notice the URL format:

    • The base URL is
    • /trunk appended at the end

    Before you run svn export, it’s good to first verify the content of the directory with:

    svn ls

    For a Generic git Repo:

    If you want to download files, not clone the repository with history, you can do this with git-archive.

    git-archive makes a compressed zip or tar archive of a git repository. Some things that make it special:

    1. You can choose which files or directories in the git repository to archive.
    2. It doesn’t archive the .git/ folder, or any untracked files in the repository it’s run on.
    3. You can archive a specific branch, tag, or commit. Projects managed with git often use this to generate archives of versions of the project (beta, release, 2.0, etc.) for users to download.

    An example of creating an archive of the docs/usage directory from a remote repo you’re connected to with ssh:

    # in terminal
    $ git archive --format tar --remote ssh:// HEAD docs/usage > /tmp/usage_docs.tgz

    More information in this blog post and the git documentation.

    Note on GitHub Repos:

    GitHub doesn’t allow git-archive access. ☹️

    I’ve created an open source project, called GitHubFolderDownloader. It lets you to download a single folder of a repository without cloning or downloading the whole repository.

    You cannot; unlike Subversion, where each subdirectory can be checked out individually, Git operates on a whole-repository basis.

    For projects where finer-grained access is necessary, you can use submodules — each submodule is a separate Git project, and thus can be cloned individually.

    It is conceivable that a Git front-end (e.g. GitHub’s web interface, or gitweb) could choose to provide an interface for you to extract a given folder, but to my knowledge none of them do that (though they do let you download individual files, so if the folder does not contain too many files, that is an option)

    Edit – GitHub actually offers access via SVN, which would allow you to do just this (as per comment). See for latest instructions on how to do this

    If you truly just want to just “download” the folder and not “clone” it (for development), the easiest way to simply get a copy of the most recent version of the repository (and therefore a folder/file within it), without needing to clone the whole repo or even install git in the first place, is to download a zip archive (for any repo, fork, branch, commit, etc.) by going to the desired repository/fork/branch/commit on GitHub (e.g. http(s)://<user>/<repo>/commit/<Sha1> for a copy of the files as they were after a specific commit) and selecting the Downloads button near the upper-right.

    This archive format contains none of the git-repo magic, just the tracked files themselves (and perhaps a few .gitignore files if they were tracked, but you can ignore those :p) – that means that if the code changes and you want to stay on top, you’ll have to manually re-download it, and it also means you won’t be able to use it as a git repository…

    Not sure if that’s what you’re looking for in this case (again, “download”/view vs “clone”/develop), but it can be useful nonetheless…

    Nothing wrong with other answers but I just thought I’d share step-by-step instructions for those wandering through this process for the first time.

    How to download a single folder from a github repository (Mac OS X):

    ~ To open Terminal just click spotlight and type terminal then hit enter

    1. On a Mac you likely already have SVN (to test just open terminal and
      type “svn” or “which svn” ~ without the quote marks)
    2. On Github: Locate the Github path to your git folder (not the repo) by clicking the specific folder name within a repo
    3. Copy the path from the address bar of the browser
    4. Open Terminal and type: svn export
    5. Next paste in the address (eg.):
    6. Replace the words: tree/master
    7. with the word: trunk
    8. Type in the destination folder for the files (in this example, I
      store the target folder inside of the Downloads folder for the
      current user)
    9. Here space is just the spacebar not the word (space) ~/Downloads/HeadsUpUI
    10. The final terminal command shows the full command to download the
      folder (compare the address to step 5) svn export

    BTW – If you are on Windows or some other platform you can find a binary download of subversion (svn) at

    ~ If you want to checkout the folder rather than simply download it try using the svn help (tldr: replace export with checkout)

    1.Click on this link
    2.Paste link of Github folder you want to download.
    3.Click on search it will shows all files for downloading.
    Note:-Using search there is no need to enter token key ;)..keep it simple(y)

    It’s one of the few places where SVN is better then GIT.

    In the end we’ve gravitated towards three options:

    1. Use wget to grab the dat from github (using the raw file view)
    2. Have upstream projects publish the required data subset as build artifacts
    3. Give up and use the full checkout. It’s big hit on the first build but unless you get lot of traffic, it’s not too much hassle in
      the following builds.

    Whoever is working on specific folder he needs to clone that particular folder itself , todo so please follow below steps ** — by using SPARSE CHECKOUT — **

    Step 1: Create a directory.

    Step 2: Initialize a Git repository. (git init)

    Step 3: Enable Sparse Checkouts. (git config core.sparsecheckout true)

    Step 4: Tell Git which directories you want (echo 2015/brand/May( refer to folder you want to work on) >> .git/info/sparse-checkout)

    Step 5: Add the remote (git remote -f add origin

    Final Step 6: Fetch the files (git pull origin master )

    Another specific example:

    Like I want to download ‘iOS Pro Geo’ folder from the url

    and I can do so via

    svn checkout

    Note trunk in the path

    Edited: (as per Tommie C’s comment)

    Yes, using export instead of checkout would give a clean copy without extra git repository files.

    svn export

    Edited: If tree/master is not there in url then Fork it and it will be there in Forked url.

    Just to amplify the answers above, a real example from a real GitHub repository to a local directory would be:

    svn ls
    svn export  /temp/SvnExport/Washburn

    Sometimes a concrete example helps clarify the substitutions proposed.

    I work with CentOS 7 servers on which I don’t have root access, nor git, svn, etc (nor want to!) so made a python script to download any github folder:

    Usage is simple, just copy the relevant part from a github project, let’s say the project is, and you want a folder where some source files are only, then you need to do something like:

    $ python "/MaxCDN/php-maxcdn/tree/master/src" /my/target/dir/
    (will create target folder if doesn’t exist)

    It requires lxml library, can be installed with easy_install lxml
    If you don’t have root access (like me) you can create a file into your $HOME dir with these contents:


    And easy_install lxml will just work (ref:

    If the directoy you want to download is a separated library, it’s better to create an other git repo, and then to use the git submodule function.

    Of course, you have to be the owner of the initial repo you want

    If you need to do it programatically and you don’t want to rely on SVN, you can use GitHub API to download all the contents recursively.

    For inspiration, here’s my ruby gist:

    To export a directory from GitHub, replace “/tree/master/” in the directory’s url with “/trunk/”.

    For example, to export the directory from the following URL:

    run the following command:

    svn export

    Our team wrote a bash script to do this because we didn’t want to have to install SVN on our bare bones server.

    It uses the github API and can be run from the command line like this:

    I use linux so , put this in ~/.bashrc , called even 😀 $HOME/.bashrc

    svn checkout ${a/tree\/master/trunk}

    then refresh the shell with

    source ~/.bashrc 

    then use it with git-downloadfolder blablabla 😀

    You can do a simple download of the directory tree:

    git archive --remote HEAD:foo | tar xf -

    But if you mean to check it out, and be able to do commits and push them back, no you can’t do that.

    Git Baby is a git and github fan, let's start git clone.