Data report"State of code review 2024" is now liveRead the full report

How to download from GitHub

Greg Foster
Greg Foster
Graphite software engineer

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.

To download individual files from a GitHub repository:

  1. Navigate to the file: Go to the main page of the repository on GitHub.
  2. Open the file: Click on the file you wish to download.
  3. 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.
  4. Save the file: Right-click on the page and choose “Save Page As…” or use CTRL+S (on Windows/Linux) or CMD+S (on macOS) to save the file to your desired location.

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:

Terminal
curl -O [URL]

or

Terminal
wget [URL]

Replace [URL] with the actual URL of the file.

GitHub does not provide a direct method to download individual folders or directories from a repository via the web interface. However, there are workarounds:

To download a specific folder, you often need to download the entire repository and then extract the desired folder locally:

  1. Navigate to the repository main page.
  2. Click on the “Code” button and then click “Download ZIP”.
  3. Extract the ZIP file locally and access the specific folder you need.

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:

    Terminal
    git 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.

Downloading an entire GitHub repository is straightforward:

  1. Navigate to the repository on GitHub.
  2. Click on the “Code” button right above the list of files.
  3. Choose “Download ZIP”. This will download a ZIP file containing the entire repository to your local machine.

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:

Terminal
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.

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2