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.
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 is one of the largest developer resources, and an absolute must-know for aspiring web developers to explore and share projects online.
If you’re just starting out with git and GitHub, taking open-source code from GitHub to experiment with or add to your own projects is one great way to learn or develop your own apps. You can even connect your GitHub repository to your preferred hosting to deploy and test your apps. To do that, you’ll need to learn the basics: getting a file from GitHub onto your computer.
In this post, we’ll show you how to download different resources from GitHub. We’ll cover:
Let’s get started.
How to Download a File From GitHub
To download a single file from GitHub, follow these steps:
1. Navigate to the GitHub repository page that contains the file. If it’s a public repository, you can visit the page without logging in. If it’s a private repository, you’ll need to log in and have the proper permissions to access it.
2. From the main repository page, locate the file you want to download. You can do this by navigating the folders, or by clicking Go to File near the top of the page. This opens a list of all files in the repository that you can search.
3. Click the file you want to download. This will open the file in GitHub.
4. On the file page, click the Raw button. This opens the raw code in your browser.
5. Right-click the page and select Save as…, then name the file and choose where to save it on your device.
We're committed to your privacy. HubSpot uses the information you provide to us to contact you about our relevant content, products, and services. You may unsubscribe from these communications at any time. For more information, check out our Privacy Policy
50 Free Coding Templates
Free code snippet templates for HTML, CSS, and JavaScript -- Plus access to GitHub.
-
Navigation Menus & Breadcrumbs Templates
-
Button Transition Templates
-
CSS Effects Templates
-
And more!
Loading your download form
You're all set!
Click this link to access this resource at any time.
Access now
How to Download a GitHub Repository
GitHub is made up of repositories. A repository is a place where all files in a project can be stored, accessed, tracked, and modified. To download a repository, follow these steps:
1. Navigate to the GitHub repository page. If it’s a public repository, you can visit the page without logging in. If it’s a private repository, you’ll need to log in and have the proper permissions to access it.
2. On the main repository page, click the green Code button.
3. In the menu that appears, click Download ZIP. The entire repository will be downloaded to your device as a zipped file.
With that, you should be able to open the file locally.
How to Download a Release From GitHub
Repositories may also put out releases, which are packaged versions of the project. To download a release:
1. Navigate to the GitHub repository page. If it’s a public repository, you can visit the page without logging in. If it’s a private repository, you’ll need to log in and have the proper permissions to access it.
2. Click Releases, located on the right-side panel.
3. You’ll be brought to a page listing releases from newest to oldest. Under the release that you want to download, locate the Assets section. Click a file under this section to download it.
You’ll be able to open this zipped file on your local device.
How to Download Multiple Files From GitHub
Unless you want to download an entire repository or release, there’s currently no way to bulk-download multiple files from GitHub. Depending on how many files you need from a repository, it may be best to download each individual file you need, or download the entire repository/release and delete the files you don’t need.
Get files from GitHub.
There’s a lot to learn when it comes to using GitHub — the platform packs a ton of features, and it can seem intimidating to newcomers. However, GitHub does an excellent job of making its tools simple and accessible. Case in point: downloading a single file or an entire repository is possible with just a few clicks.
We're committed to your privacy. HubSpot uses the information you provide to us to contact you about our relevant content, products, and services. You may unsubscribe from these communications at any time. For more information, check out our Privacy Policy
50 Free Coding Templates
Free code snippet templates for HTML, CSS, and JavaScript -- Plus access to GitHub.
-
Navigation Menus & Breadcrumbs Templates
-
Button Transition Templates
-
CSS Effects Templates
-
And more!
Loading your download form
You're all set!
Click this link to access this resource at any time.
Access now