Understanding how to download files, directories, or entire projects from GitHub is fundamental for those who wish to collaborate on or utilize projects hosted there. This guide will walk you through the steps and methods to download files, folders, directories, and entire repositories from GitHub.
How to download files from GitHub
Single file download
To download individual files from a GitHub repository:
- Navigate to the file: Go to the main page of the repository on GitHub.
- Open the file: Click on the file you wish to download.
- Download the file: Click the “Raw” button near the top right of the file view. This will open the file in a new tab in its raw format.
- Save the file: Right-click on the page and choose “Save Page As…” or use
CTRL+S
(on Windows/Linux) orCMD+S
(on macOS) to save the file to your desired location.
Using cURL or wget
For those familiar with the command line, downloading via cURL
or wget
is an efficient method. After opening the file in raw mode as described above, copy the URL from your browser's address bar and use the following command:
curl -O [URL]
or
wget [URL]
Replace [URL]
with the actual URL of the file.
How to download a folder from GitHub
GitHub does not provide a direct method to download individual folders or directories from a repository via the web interface. However, there are workarounds:
Download using GitHub’s web interface (entire repository)
To download a specific folder, you often need to download the entire repository and then extract the desired folder locally:
- Navigate to the repository main page.
- Click on the “Code” button and then click “Download ZIP”.
- Extract the ZIP file locally and access the specific folder you need.
Use a third-party tool or Git
Third-party tools like DownGit
or using Git commands can help download specific folders:
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:
Terminalgit clone [repository-url]cd [repository-name]Replace
[repository-url]
and[repository-name]
with the actual URL and name of the repository.For more detailed instructions on using the
git clone
command see this guide on cloning with Git.
How to download an entire project or repository
Downloading an entire GitHub repository is straightforward:
- Navigate to the repository on GitHub.
- Click on the “Code” button right above the list of files.
- Choose “Download ZIP”. This will download a ZIP file containing the entire repository to your local machine.
Using Git
If you prefer using Git, you can clone the repository to your local machine, which provides the additional benefit of keeping the entire Git history:
git clone [repository-url]
This command creates a local copy of the repository on your machine, including all branches and commits.
For further instructions on cloning entire repositories, see this guide on cloning Git repos.