0

How To Download Files From Github

Posted by Brad on January 11, 2019

If you’ve ever used Github before, you know that it’s not immediately clear on how to download files from the platform. It’s one of the more complicated platform, as it isn’t directly meant for direct file sharing, but for development instead. Granted, one of the big 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 businesses that don’t want their code seen by the public. Github, however, still handles downloading files differently than other places.

So if you’re not entirely sure how you can download files from projects (or entire projects) from Github, we’re going to show you how. Let’s get started.

Downloading a file

Most public repositories can be downloaded for free, without even a user account. This is because public repositories are considered to be codebases that are open source. That said, unless the owner of the codebase checks a box otherwise, their codebase can be downloaded onto your computer, packed into a .zip file.

So, if you go to a public codebase — such as this Tip Calculator that I built — you’ll notice that in the top-right corner is a green button that says Clone or Download. Click on the button, and then in the dropdown, select Download ZIP. All of the files will begin downloading to your computer, usually in your Downloads folder.

Then, open your Downloads folder on your computer and find the ZIP file. You’ll want to right-click it and choose the option that says “Unzip” or “Uncompress”, and then select a folder where you want the files to end up.

Finally, navigate to that selected folder, and you’ll find all of those Github files that we downloaded right there!

That’s a fairly small codebase, with only a couple of files in it. If you go to Wes Bos’ JavaScript 30 repository on Github, you’ll notice that — since it is a public repository — it can be downloaded the same way.

There’s a better way to “download” files

While the way we outlined is simple and straightforward, it’s most optimal for simply viewing the code files, not experimenting. If you’re planning on downloading Github files to experiment with, the best way would be to “fork” the project. A fork is simply your own copy of a repository.

Forking a repository comes with a number of benefits. It gives you your own copy on your Github account that allows you to freely experiment with changes without affecting the original project. For example, you could find a bug in my Tip Calculator or want to add your own features. So, you could “fork” my Tip Calculator, creating a copy on your Github account. Here, you could mess around the code and experiment with it without affecting the original project, because this would be your copy or “fork.”  Most commonly, forks are used to either propose changes to someone else’s project, like fixing a bug or adding a feature as we mentioned.

So, how do you fork a public repository? It’s actually quite easy. Before we get started, you need to create a free Github account, as you’ll need somewhere to store your fork. You can head to www.github.com and do this right now.

Once you have your account created, you can fork a public repository to your account. 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 the button.

It could take a couple of seconds to a few minutes, but Github will then clone or “fork” that project over to your own GitHub account. Once it’s done, it’ll immediately show you the project under your Github username. To verify, you can click on your profile icon in the navigation bar at the top-right, and then select the option that says Your Repositories. In your list of repositories, you should see the JavaScript 30 course codebase.

Now, you can change and experiment with the code all you want, and it won’t affect the original project files of the original owner. 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 properly — it can be merged into the original codebase as production code.

Closing

As you can see, downloading files and whole projects from Github is actually quite easy. In just a couple of minutes, you can have an entire project downloaded onto your computer, or even forked to your own Github account. It doesn’t take much to mess around with the code in your fork to see what affects what, and then eventually, you might even be able to create your first pull request! Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *


Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.