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.
On GitHub.com, navigate to the main page of the repository.
Above the list of files, click Code.
Click Download ZIP.
On GitHub.com, navigate to the main page of the repository.
To the right of the list of files, click Releases.
Scroll down to the "Assets" section of the release.
To download the source code, click Source code (zip) or Source code (tar.gz).
On GitHub.com, navigate to the main page of the repository.
To the right of the list of files, click Releases.
At the top of the Releases page, click Tags.
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.
Type of archive | Example | URL |
---|---|---|
Branch | main | https://github.com/github/codeql/archive/refs/heads/main.tar.gz |
Tag | codeql-cli/v2.12.0 | https://github.com/github/codeql/archive/refs/tags/codeql-cli/v2.12.0.zip |
Commit | aef66c4 | https://github.com/github/codeql/archive/aef66c462abe817e33aad91d97aa782a1e2ad2c7.zip |
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.
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.