Sixty-five million developers and three million organizations can’t be wrong. Hosting over 200 million code repositories, GitHub is the development platform of choice for individual coders and companies across the globe. Developers use GitHub to build, maintain, and even distribute their software so users like you can download files and view code straight from GitHub.

GitHub makes it easy to download and view an app’s source code. This guide will show you how to directly download files from GitHub’s website so you can view a project’s code yourself.

Table of Contents

    Install a Code Viewer

    Before you download any code, you’ll need to install a program capable of viewing that code. Visual Studio Code is a free, open source, and streamlined code editor that allows users to view and debug code and run tasks. 

    Download and install Visual Studio Code by following the installation wizard. Then you’ll be ready to view files and code that you can download from GitHub. 

    There are many different code editors. If a project was created with a different IDE (integrated development environment), then Visual Studio might not be ideal for editing that code. Having said that, Visual Studio Code will allow you to edit the code of most of the projects on GitHub, and it will always work if all you want to do is view the code. 

    Downloading the Most Recent Release of a Project on GitHub

    Let’s say you’re a programmer who wants to download the project files for an open-source piece of software. On GitHub, project files are posted in repositories, and each project has a repository home page. You don’t need to have a user account on GitHub to view or download files. 

    Follow these steps to download the most recent release of the project you’re interested in.

    1. Go to github.com.
    2. Search for the project by name in GitHub’s search box. 
    1. Navigate to the home page for the repository.
    1. Find the Releases section and select the latest version. On GitHub’s desktop site, Releases are in the sidebar on the right. Alternatively, you can add /releases to the repository URL. The release at the top will be the most recent.
    1. Next, find and expand the Assets section. 
    1. Since you want to view the code, download the source code .zip file. Linux users should download the source code tar.gz file.
    1. Extract the source code archive you downloaded in step 6.
    2. Switch to Visual Code Editor and select File > Open Folder. Navigate and select the folder you extracted in step 7.
    1. Press the Select Folder button.
    2.  In Visual Studio Code, you’ll see the project listed on the left. You can expand the dropdown arrows to see all the files included in the project. 
    1. Select a project file in the panel on the left, and the code will appear in the workspace on the right. 

    The steps above walk you through how to view the files from the most recent release of a project on GitHub. But what if you want to view files from a specific branch of the project?

    Downloading From a Specific Branch

    In GitHub, a repository can have multiple branches. Every branch has a unique name, and consists of a set of code changes. It’s a copy of a particular part of the code at a particular point in time where you can make changes without destroying the original. Code changes are made inside branches and then, if requested and approved, can be merged back into the main working version of the project called the master branch

    Let’s imagine that you want to download and view files from a specific branch of a project on GitHub. To do so, follow these steps:

    1. Search for the project by name and navigate to the project’s repository home page. 
    2. Find the branch dropdown, and select the branch you want to download. Typically, the Master branch contains the most recent code, but not always.
    1. Now that you have selected the branch you want, find and select the green Code button, choosing either Download Zip or, if you see the option, Open with Visual Studio. (You may also see an option to Open with GitHub Desktop.)
    1. Extract the zip file and open the extracted folder from within Visual Studio Code by following steps 7-11 in the section above.

    By following the steps above, you can view the code from a specific branch of a project on GitHub. Next, we’ll discuss how to drill down even farther and download files from a specific commit.

    Downloading From a Specific Commit

    Every time a code change is applied to a repository, it is added via a commit. The commit contains all of the changes since the last code update. You may want to download from a specific commit if you’re trying to debug issues that were caused by a recent code change.

    1. Navigate to the repository home page and select the branch you want to work with. Normally, this will be the master branch.
    2. Find and select the Commits link.
    1. Choose the commit you want to download by selecting the title of the commit.
    1. Now you’re on the page for the commit you selected. Next, select the Browse files button.
    1. Find and select the green Code button, and choose either Download zip or, if it’s available, Open with Visual Studio.
    2. Finally, extract the zip file and open the extracted folder in Visual Studio Code. 

    There’s So Much More to GitHub

    Downloading and viewing project files from GitHub is just the tip of the iceberg. Eventually, you may want to fork a repository, clone it to a local repository, commit changes, push changes back to your fork, and then submit a pull request asking the project owner to merge your changes into the source repository.