How to download files from GitHub

If you've used GitHub before, you know it's not immediately clear how to download files from the platform. It is one of the more complicated platforms, as it is not directly intended for direct file sharing, but rather for development. Admittedly, one of the great things about GitHub is that all of the public repositories are open source, and people are encouraged to contribute - there are private repositories, but these are generally used for development purposes within companies that don't want their code to be seen by the public. GitHub, however, still handles file uploads differently than other places.



So if you're not quite sure how you can download files from projects (or entire projects) from GitHub, we'll show you how. Let's start.

Download a file from GitHub

Most public repositories can be downloaded for free, without even a user account. This is because public repositories are considered open source codebases. That said, unless the codebase owner ticks a box to the contrary, their codebase can be downloaded to your computer, packaged in a .zip file.

  1. So if you go into a public code base — like this Type Calculator I built — you'll notice that in the top right corner there's a green button that says Clone or download, click on the pimple.
  2. Then, from the drop-down list, select Download ZIP. All the files will start downloading to your computer, usually to your Downloads folder.
  3. Next, open your Downloads folder on your computer and find the ZIP file. You will want to right click on it and choose the option that says Extract all ..., Unzip, or Relax, then select a folder where you want the files to end up.
  4. Finally, navigate to the selected folder and there you will find all the Github files we have uploaded!

It's quite a small codebase, with only a few files in it. If you go to The Wes Bos JavaScript Repository 30 on Github, you'll notice that since it's a public repository, it can be downloaded the same way.



Downloading GitHub Files Using Commands

Alternatively, you can easily clone a file or repository using a few simple commands on GitHub. For this to work, you need to install the Git tools. We will be installing the same tip calculator from the command line in this demo.

  1. Copy the URL from your address bar or the same menu from which you downloaded the zip file.
  2. Open Git Bash, type “CD Downloads” and press Enter. This will take you to the Downloads folder in the command window, you can also type in the file location where you want to save the file.
  3. Now type “git clone https://github.com/bdward16/tip-calculator.git” and hit Enter.
  4. Using this method, files are automatically decompressed upon download.

There's a better way to download files

Although the way we have described is simple and straightforward, it is most optimal for just viewing the code files, not for experimenting. If you plan to download GitHub files for experimentation, the best way would be to fork the project. A fork is simply your own copy of a repository.

Forking a repository has a number of advantages. It gives you your own copy on your GitHub account which allows you to freely experiment with changes without affecting the original project. For example, you might find a bug in my tip calculator or want to add your own features. Thus, you can "fork" my tip calculator, by creating a copy on your GitHub account. Here you can modify the code and experiment with it without affecting the original project, as it would be your copy or "fork".



Most often, forks are used to propose changes to someone else's project, like fixing a bug or adding a feature like we mentioned.

So how do you fork a public repository? It's actually quite easy. Before you start, you need to create a free GitHub account, because you'll need a place to store your fork. You can head over to www.github.com and do it now.


Once your account is created, you can create a public repository on your account.

  1. For example, you can head over to the public repository for Wes Bos' 30 Days of JavaScript training course, and in the top right corner you'll see a button that says fork. Click on the button.
  2. It may take a few seconds to a few minutes, but GitHub will then clone or "fork" this project to your own GitHub account. Once done, it will immediately show you the project under your GitHub username.
  3. To check, you can click on your profile icon in the top right navigation bar and then select the option that says Your repositories. In your list of repositories, you should see the JavaScript 30 course code base.

Now you can modify and experiment with the code as you wish, and it will not affect the original owner's original project files. If you change some code, fix a bug, or add a new feature, you can create something called a "Pull Request", where that change can be discussed. If the original project owner likes the change – and it works well – it can be merged into the original codebase as production code.


Adjustable velcro closure

As you can see, downloading files and entire projects from GitHub is actually quite simple. In just a few minutes, you can download an entire project to your computer, or even upload it to your own GitHub account. It doesn't take much to play around with your fork code to see what affects what, and then eventually you can even create your first pull request! Happy coding!

Audio Video How to download files from GitHub
add a comment of How to download files from GitHub
Comment sent successfully! We will review it in the next few hours.