You can download a file/folder from github

Simply use: svn export <repo>/trunk/<folder>

Ex: svn export https://github.com/lodash/lodash/trunk/docs

Note: You may first list the contents of the folder in terminal using svn ls <repo>/trunk/folder

(yes, that's svn here. apparently in 2016 you still need svn to simply download some github files)

Answer from Anona112 on Stack Overflow
Discussions

git - Shortest way to download from GitHub - Unix & Linux Stack Exchange
This is, how I download various master branches from GitHub, and I aim to have a prettier script (and maybe more reliable?). wget -P ~/ https://github.com/user/repository/archive/master.zip unzip ~/ More on unix.stackexchange.com
🌐 unix.stackexchange.com
git - Download specific files from github in command line, not clone the entire repo - Stack Overflow
You can try github-files-fetcher, it is a command line tool which downloads a single folder or file from a GitHub repo. More on stackoverflow.com
🌐 stackoverflow.com
Plain and simple: How to download files from github?
https://docs.github.com/en/get-started/using-git/about-git You use git and clone the repository. More on reddit.com
🌐 r/learnprogramming
4
0
May 6, 2023
Download files from Github without Git using PowerShell
Crazy, I was just looking to do something similar with GitLab/curl/private token for a project for FileLogBeat and a yml file. Thanks. More on reddit.com
🌐 r/PowerShell
2
23
May 31, 2017
Top answer
1 of 16
1844

Update April 2021: there are a few tools created by the community that can do this for you:

  • Download Directory (Credits to fregante)
    • It has also been integrated into the excellent Refined GitHub Chrome extension as a button in the GitHub web user interface.
  • GitZip (Credits to Kino—see his answer here)
  • DownGit (Credits to Minhas Kamal—see his answer here)

Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.


Original (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.

Update November 2024: The Subversion support has been removed after January 8, 2024: https://github.blog/news-insights/product-news/sunsetting-subversion-support/. The rest of this answer is outdated and describes the functionality in the past.

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. Navigate to the folder you want to download. Let's download /test from master branch.

  2. Modify the URL for subversion. Replace tree/master with trunk.

    https://github.com/lodash/lodash/tree/master/test

    https://github.com/lodash/lodash/trunk/test

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

    svn checkout https://github.com/lodash/lodash/trunk/test
    

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/foo instead. The full path looks like branches/foo/foldername
  • Pro tip: 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.

2 of 16
1187

Go to DownGit → Enter Your URL → Download!

You can directly download or create download link for any GitHub public directory or file from DownGit:



You may also configure properties of the downloaded file—detailed usage.


Disclaimer: I fell into the same problem as the question-asker and could not find any simple solution. So, I developed this tool for my own use first, and then opened it for everyone :)

🌐
101workbook
datascience.101workbook.org › 07-wrangling › 01-file-access › 03e-download-github-folders-svn
Downloading a single folder or file from GitHub - Data Science Workbook
2 weeks ago - #!/bin/bash echo "----------------" ... "----------------" echo "" URL=`echo $1` folder=`echo $URL | sed 's|tree/master|trunk|g'` svn export $folder ......
Top answer
1 of 8
43

Copy the specific file's raw link from GitHub.(As you open the file in Github, on the top right corner you can see the option to open the file in raw mode. Open it in raw mode and copy the URL)

Now use curl or wget command in command line to download the file.

curl -o filename raw-link-to-file

or

wget -O filename raw-link-to-file

Please note that

2 of 8
41

If you go to the page and view the links provided by "raw" (in the top left corner, when viewing the file). You will see, that you can access it by:

https://github.com/username/repository/raw/$changeset_hash/path/to/file

Instead of $changeset_hash you can also provide a branch (e.g. master) or tag.

You can retrieve the raw file using something like wget.

Accessing a single file directly from a .git-repository is not possible (as far as I know), because of how the data is stored.

edit: When you want to access a file from a private repo, you first have to create an access token with the appropriate permissions in your account settings. Instead of calling the url above you can then use github's API to access the content of a file. Be sure to use the Accept-header for custom media types to get the raw data. This might look something like this:

curl \
  -H 'Authorization: token $YOUR_TOKEN' \
  -H 'Accept: application/vnd.github.v3.raw' \
  -O \
  -L 'https://api.github.com/repos/:owner/:repo/contents/:path'

The -O will save the contents in a local file with the same name as the remote file name. For easier use you can wrap it in a script. @Chris_Withers suggested an edit with a nice python snippet that unfortunately got rejected as to big of a change to the answer.

🌐
GitKraken
gitkraken.com › home › learn › how to download from github: master repositories, files, and releases
GitHub Download | How to Download from GitHub | Repos, Folders, & Files
February 5, 2024 - To download a folder from GitHub, navigate to your desired repository, select the folder you want to download from GitHub, copy the URL, navigate to https://download-directory.github.io/ and paste the URL into the text box, and hit enter.
Find elsewhere
🌐
Wikihow
wikihow.com › computers and electronics › software › programming › how to download a folder from github: step-by-step guide
How to Download a Folder from GitHub: Step-by-Step Guide
September 2, 2025 - Learn how to download a single folder from any GitHub repoDo you need to download a folder from GitHub? GitHub doesn't give you the option to download a specific folder directly, but you can still easily do so using a third-party tool....
🌐
YouTube
youtube.com › watch
How to Download Selected Files & Folder from Github (via Commands) - YouTube
How to download github files and folders easily? How to download specific file or folder from a github repository by using a command line tool. I shared a vi...
Published   November 5, 2023
🌐
Linux Handbook
linuxhandbook.com › github-download-files
How to Download Files and Folders From GitHub
March 20, 2024 - Location of the Download Raw File button in a GitHub Repo File Page · And the file will be downloaded on your system. Nice, isn't it? Let's see about downloading a single folder from GitHub.
🌐
Medium
berrasari.medium.com › learn-how-to-download-folders-from-github-now-83798fd4a242
Learn How to Download Folders From GitHub Now | by Berra Sarı | Medium
August 19, 2023 - To do this, you have to first open a terminal window and enter a command such as git clone <repository-url> <target-directory>. Once the repository has cloned, you can then navigate to the target directory and download the folder as you would ...
🌐
Coderwall
coderwall.com › p › o2fasg › how-to-download-a-project-subdirectory-from-github
How to download a project subdirectory from GitHub (Example)
May 11, 2021 - If you want to download an entire project from GitHub without version control data, you can use the Download ZIP option of the website. Alternatively, you could use command line tools, for example:
🌐
Educative
educative.io › answers › how-to-download-a-single-folder-or-directory-from-a-github-repo
How to download a single folder or directory from a GitHub repo
When we download a single folder, ... comes with downloading the entire repository. For example, a UI engineer might only want the UI folder from the entire micro-service repo. We’ll use one of the public repos for this example. Here is the link to it. ... Line 1: We create ...
🌐
Medium
berrasari.medium.com › step-by-step-guide-how-to-download-a-folder-from-github-fd23060090c9
Step-by-Step Guide: How to Download a Folder from GitHub | by Berra Sarı | Medium
August 31, 2023 - Now that you have created a local repository, you can download the folder from GitHub. To do this, type the command git remote add followed by the URL of the repository. Then, type git pull to download the files from GitHub.
🌐
Graphite
graphite.com › guides › how-to-download-a-folder-from-github
How to download a folder from GitHub - Graphite
This guide explains the process of downloading a specific folder from a GitHub repository, covering multiple methods and tools.
🌐
Quora
quora.com › How-can-I-download-files-from-GitHub-using-git
How to download files from GitHub using git - Quora
Answer (1 of 6): If you have the git CMD installed on your PC, then you just have to use the command ‘git clone’ followed by the url of the repository you need to download. The complete repository will be copied onto your device as your ...
🌐
Graphite
graphite.com › guides › github-download
How to download from GitHub - Graphite
Using DownGit: Navigate to DownGit, paste the URL of the folder, and click 'Download' to get the directory alone. Using Git: If you have Git installed, you can clone the repository and then simply keep the directory you need: ... Replace ...