How do you download from GitHub?

03 Apr.,2024

 

You can download a snapshot of any branch, tag, or specific commit from GitHub.com. These snapshots are generated by the git archive command in one of two formats: tarball or zipball. Snapshots don't contain the entire repository history. If you want the entire history, you can clone the repository. For more information, see "Cloning a repository."

You can download the source code archives in three ways.

  1. On GitHub.com, navigate to the main page of the repository.

  2. Above the list of files, click Code.

  3. Click Download ZIP.

  1. On GitHub.com, navigate to the main page of the repository.

  2. To the right of the list of files, click Releases.

  3. Scroll down to the "Assets" section of the release.

  4. To download the source code, click Source code (zip) or Source code (tar.gz).

  1. On GitHub.com, navigate to the main page of the repository.

  2. To the right of the list of files, click Releases.

  3. At the top of the Releases page, click Tags.

  4. To download the source code, click zip or tar.gz.

Source code archives are available at specific URLs for each repository. For example, consider the repository github/codeql. There are different URLs for downloading a branch, a tag, or a specific commit ID.

Note: You can use either .zip or .tar.gz in the URLs above to request a zipball or tarball respectively.

Source code archives are generated on request, cached for a while, and then deleted. If the same archive is requested again in the future, it'll be regenerated. It's important to understand what guarantees GitHub makes about source code archives.

  • An archive of a commit ID will always have the same file contents whenever it's requested, assuming the commit ID is still in the repository and the repository's name has not changed.
  • Because branches and tags can move to different commit IDs, future downloads of an archive may have different contents than previously downloaded archives of the same branch or tag. Assuming the branch or tag still points at the same commit ID, it will have the same file contents.
  • The exact compression settings used to generate a zipball or tarball may change over time. The extracted contents won't change if the branch or tag doesn't change, but the outer compressed archive may have a different byte layout. GitHub will give at least six months' notice before changing compression settings.
  • The name of the repository is part of the directory structure inside the archive. Therefore, if the repository name changes, the root directory name will change as well.

If you rely on stability of source code archives for reproducibility (ensuring you always get identical files inside the archive), we recommend using the archives REST API with a commit ID for :ref. Using the commit ID ensures you'll always get the same file contents inside the archive and you’ll be immune to repositories rewriting tags or moving branch heads.

If you rely on stability of archives for security (for example: to ensure you don't attempt to unzip a maliciously-crafted file), we recommend using releases instead of using source downloads. For more information, see "About releases."

You can use something like this third-party GitHub action to create and push these files as part of your release process. The Release Assets REST API can later be used to retrieve them.

GitHub.com is home to millions of open-source software projects, that you can copy, customize, and use for your own purposes.

There are different ways to get a copy of a repository's files on GitHub. You can:

  • Download a snapshot of a repository's files as a zip file to your own (local) computer.
  • Clone a repository to your local computer using Git.
  • Fork a repository to create a new repository on GitHub.

Each of these methods has its own use case, which we'll explain in the next section.

This tutorial focuses on downloading a repository's files to your local computer. For example, if you've found some interesting content in a repository on GitHub, downloading is a simple way to get a copy of the content, without using Git or applying version control.

TermDefinitionUse caseDownloadTo save a snapshot of a repository's files to your local computer.You want to use or customize the content of the files, but you're not interested in applying version control.CloneTo make a full copy of a repository's data, including all versions of every file and folder.You want to work on a full copy of the repository on your local computer, using Git to track and manage your changes. You likely intend to sync these locally-made changes with the GitHub-hosted repository. For more information, see "Cloning a repository."ForkTo create a new repository on GitHub, linked to your personal account, that shares code and visibility settings with the original ("upstream") repository.You want to use the original repository's data as a basis for your own project on GitHub. Or, you want to use the fork to propose changes to the original ("upstream") repository. After forking the repository, you still might want to clone the repository, so that you can work on the changes on your local computer. For more information, see "Fork a repository."
  • You must have a GitHub account.

For the tutorial, we'll use a demo repository (octocat/Spoon-Knife).

  1. Navigate to octocat/Spoon-Knife.

  2. Above the list of files, click Code.

  3. Click Download ZIP.

You now have a copy of the repository's files saved as a zip file on your local computer. You can edit and customize the files for your own purposes.

  • In the next tutorial, "Uploading a project to GitHub," you'll learn how to upload your own files to a remote repository on GitHub.

How do you download from GitHub?

Downloading files from GitHub