The fastest way to get a single file from GitHub

If you need one file from a GitHub repository, you do not have to download the entire project. Open the file in your browser, click the Raw button, right-click the page, and select Save As. This saves just that file to your computer in seconds.

For most people, this is the only method you will need. The steps below walk you through it for any file type — code, documents, images, or anything else stored on GitHub.

Key Takeaways

  • The Raw button on any GitHub file page gives you a direct link you can save to your computer without downloading the whole repository.
  • Right-click and Save As works for text files, images, and most other file types, but some browsers may open the file instead of saving it.
  • If Save As does not work, you can copy the Raw link and paste it into a download manager or use it in other tools.
  • Downloading an entire repository with the green Code button is slower but necessary if you need multiple files or a project's folder structure.

Download a single file using the Raw button

Navigate to the file you want on GitHub. Click on the filename to open it in the file viewer. Look for the Raw button in the toolbar above the file content — it is usually near the top right, next to buttons labeled History and Blame.

Click Raw. The file will open in a new tab showing only the raw content with no GitHub interface around it. Right-click anywhere on the page and select Save As (or Save Page As in some browsers). Choose where you want to save the file on your computer and click Save. The file is now on your computer with its original name and format.

This method works for text files, code files, JSON, CSV, images, PDFs, and nearly every other file type. The only exception is very large files — GitHub may time out if the file is over 100 MB, though most files are much smaller.

What to do if Save As does not work

Some browsers open the file in a new tab instead of saving it. If this happens, look at the address bar. You will see a long URL starting with raw.githubusercontent.com. Copy this entire URL.

Open a new tab and paste the URL into the address bar, then press Enter. Right-click and select Save As again. If your browser still opens the file instead of saving it, try a different browser — Firefox and Chrome handle this differently, and one may work better for you.

Alternatively, you can paste the raw URL into a download manager or use it in command-line tools. This is less common but useful if you are automating downloads or working on a server.

Download an entire repository

If you need multiple files or the folder structure of a project, download the whole repository. Go to the main page of the repository and click the green Code button near the top right. Select Download ZIP from the menu that appears.

Your browser will download a .zip file containing the entire repository. Unzip it on your computer using your operating system's built-in tool — right-click the file and select Extract All on Windows, or double-click on Mac. This creates a folder with all the project files organized exactly as they are on GitHub.

This method is slower than downloading a single file, but it preserves the project structure and is necessary if files depend on each other or if you need to see how the project is organized.

Using Git to clone a repository

If you work with code regularly, cloning a repository with Git is faster and more flexible than downloading a ZIP file. You will need Git installed on your computer first — download it from git-scm.com if you do not have it.

Go to the repository page and click the green Code button. Copy the HTTPS URL (or SSH if you have set up SSH keys). Open your terminal or command prompt, navigate to the folder where you want the project, and type: git clone [paste the URL you copied]. Press Enter and Git downloads the entire repository with its full history.

Cloning is most useful if you plan to update the files later or contribute to the project. For a one-time download of files you will not change, the ZIP method is simpler.

Downloading files from a specific branch or release

GitHub repositories often have multiple branches — different versions of the code. By default, you download from the main branch. To download from a different branch, click the branch selector (usually labeled main or master) near the top left of the file list, select the branch you want, then follow the same download steps.

If the repository has releases, you can download a specific release version instead of the current development code. Scroll down on the repository home page to the Releases section on the right side, click the release you want, and download the file or ZIP from there. Releases are often more stable than the latest code.

Troubleshooting common download problems

If a file will not download, check that you are clicking Raw for single files, not the regular file view. The regular view shows the GitHub interface and will not save properly. Also verify that your browser is not blocking downloads — check your download settings if files disappear after clicking Save.

If you get a message that the file is too large, GitHub has a 100 MB limit for viewing files in the browser. You can still clone the repository with Git, which has no size limit. For very large files, contact the repository owner to ask about alternative download methods.

If the repository is private, you must be logged into GitHub and have permission to view it. Public repositories require no login. If you cannot see a file you expect, check that you are on the correct branch and that the file path is correct.

Frequently Asked Questions

Do I need a GitHub account to download files?

No. Public repositories can be downloaded by anyone without logging in. Private repositories require you to be logged in and have permission from the repository owner. Creating a free GitHub account takes two minutes if you need one.

What is the difference between downloading a ZIP and cloning with Git?

Downloading a ZIP gives you the files as they are right now. Cloning with Git downloads the files and their full history, and lets you update them later with a single command. Use ZIP for a one-time download; use Git if you plan to work with the files regularly.

Can I download just a folder from a repository, not the whole thing?

Not directly from GitHub's interface. You can download the entire repository as a ZIP and delete the folders you do not need, or use a tool like DownGit that extracts specific folders. For regular use, cloning with Git and working with just the folder you need is faster.

Why does my browser open the file instead of saving it?

Some browsers default to opening text files in a new tab. Try right-clicking the Raw link itself (not the page) and selecting Save Link As. If that does not work, try a different browser or use a download manager.

Is it safe to download files from GitHub?

Public repositories are visible to everyone, so you can inspect the code before downloading. Always check what a file does before running it, especially if it is code or an executable. Stick to repositories from developers or organizations you recognize.