Open source code is all over the place, and it’s free. If you’re a programmer, you should be all over open source. Keep reading to find out how to access open-source code easily, and how it can benefit your programming projects.
Every now and then we get an email asking how to access source code for the plug-ins we’ve written. “It’s open source—it’s supposed to be free, after all,” is a common line from those who, based on traffic numbers and job titles, I would expect to be completely fluent in the ways of the world wide web. So, here you go: all you need to know about accessing our open source code.
Downloading The Source Code
Downloading a repository from GitHub takes just two clicks.
At the top of each repository, beneath the row displaying the total number of commits, branches, packages, releases, and contributors, you’ll see a green button labeled Clone or download. Click on it and select Download ZIP.
By default, this will begin downloading the current repository’s master branch as a ZIP file. When complete, all you need to do is extract the archive to a local folder on your computer. Then, using a text editor, you can open any of the repository’s files in a much quicker way that doesn’t require a browser.
If you aren’t an experienced coder, GitHub can be a little confusing at first. If you just think of it as an open directory of source code, with a readme at the top level, it’s not too intimidating. Viewing source code using GitHub is simple, both locally and through its web interface.
Create an Account
Before you get started with using GitHub, it’s best to create an account with them. Creating an account is free and will allow you to take advantage of numerous features such as forking. GitHub also has different membership levels besides the free one, but a free account should be more than enough for personal use.
Checking Out a Project
Once you have an account you can dive straight into an open source application found on GitHub. Here you can see the application’s project page, including folders and files pertaining to the application, a network graph, a list of pull requests, open issues, a wiki, and other graphs. Obviously, if you want to see the code within the files, you should click on them and you’ll be presented with the full source code. As far as interpreting the code goes, you’ll need to have some background in the programming language that the application is written in, whether it be Java, C++, Python, or something else.
Improve software you rely on
Lots of open source contributors start by being users of software they contribute to. When you find a bug in an open source software you use, you may want to look at the source to see if you can patch it yourself. If that’s the case, then contributing the patch back is the best way to ensure that your friends (and yourself when you update to the next release) will be able to benefit from it.
Forking a Project
Editing the code requires some additional steps. If you wish to copy the code without officially forking it on GitHub, you’ll need to download the project’s files and then edit them locally on your computer. However, if you’re truly looking at using the currently available source and creating your own project with it and going in your own direction, you’ll want to fork it. Forking can be accomplished with an account, and by clicking on “Fork” on the project’s page as shown in the screenshot. The next few instructions are for Linux users who should install the G.
It’s empowering to be able to make changes, even small ones
You don’t have to become a lifelong contributor to enjoy participating in open source. Have you ever seen a typo on a website, and wished someone would fix it? On an open source project, you can do just that. Open source helps people feel agency over their lives and how they experience the world, and that in itself is gratifying.
If you’d like to contribute back to the upstream project, it’s best to push any changes to your own fork of the project (or your own branch of the upstream project, but that’s only after the original author makes special arrangements). Once you’ve pushed those changes to your repository, you can go to GitHub and submit a pull request. This notifies the original author of the upstream project that you’d like him/her to review the changes that you’ve made and have them pull your changes into the upstream project. It’s a common courtesy to at least offer some of your own modifications back to the upstream project for them to pull as a thank you for forking their project. Whether they accept your request is up to them.
Meet people who are interested in similar things
Open source projects with warm, welcoming communities keep people coming back for years. Many people form lifelong friendships through their participation in open source, whether it’s running into each other at conferences or late night online chats about burritos.
Keeping Track of Upstream
If you’d like to keep track of the upstream project (the one that you forked to create your own), then you’ll need to add what’s called an additional remote. This is basically just another keyword you can use while you’re inside your application’s folder. To create the new remote, run the command.
Learn people skills
Open source offers opportunities to practice leadership and management skills, such as resolving conflicts, organizing teams of people, and prioritizing work.
Merging Upstream Changes
If you notice that the upstream project has been updated and you’d like to incorporate the changes, you can run
git pull upstream
after creating the additional remote, and GitHub will download and merge changes from upstream into your project’s files. If everything works perfectly after running that command, you can immediately run
git push origin master
to push the updates to your own project.
Some open source projects require you to compile (or build) the code yourself. But what if you don’t know how to do that? This guide is meant to be a starting reference for newcomers who want to learn more about open source software and get started with contributing, but need some guidance on how to access and learn from the source code. In other words, this guide will introduce you to some of the tools used to access, modify, and share open source code so that you can contribute more easily in the future.