Learning how to use GitHub and contribute to Open Source projects should be among the first lessons that a new programmer learns. Unfortunately, getting started with GitHub and helping with Open Source projects can seem very confusing at first. Often, new programmers aren’t sure where to start so they end up putting off learning how to use these valuable tools.
The good news is that setting up a GitHub account is easier than you might think and I have a tip that will allow even the newest programmer to start submitting Pull Requests and improving Open Source projects today.
Setting Up GitHub
The first step is to set up or sign in to your GitHub account. If you don’t have a GitHub account you can click here to create one.
Once you have created a GitHub account, take a few minutes to work on the tutorial that follows. This will teach you how to create your first repository and submit a Pull Request. Don’t worry if you don’t completely understand Pull Requests. We will talk more about them later.
One of the main benefits of having a GitHub account is that you can (and should) create repositories for all your projects. Using GitHub will not only give prospective employers a way to view your work but it will also teach you about version control, which is something all programmers should know.
With your GitHub account in place, it is time to figure out how you can help Open Source projects.
How Can You Help?
As a new programmer, one of the hardest parts about contributing to an Open Source project is finding one that needs help with something that you actually know how to do.
I ran into this problem last month when I decided to join Hacktoberfest. As someone relatively new to coding, it was hard to find projects to contribute to. I was able to complete the challenge by working on some of my own projects, but I wish I knew then what I know now.
I recently learned a great way to contribute to Open Source projects that even someone with zero coding knowledge can do. Fixing typos!
While it might sound simple, helping someone spot and correct typos in their code is a huge help. Coding typos are more common than you might think and they can be hard to spot while in the midst of writing code.
Now that you know the goal, it is time to start making a list of common coding typos.
You can start by looking at your own coding. Are there certain words that you find yourself adding a letter to or leaving a letter off of? If so, others are probably making the same mistake. Make a note of these misspellings.
Try thinking about common coding terms and ways they might be typed wrong. “Aray” instead of “array” is a great example of this. Add these typos to the list too.
You can also do a Google search for common programming typos. This will lead you to mistakes like “lenght”, “langauge”, and “prnt”. Put them on the list!
Now that you have a list of common coding typos it is time to start searching GitHub and making Pull Requests.
Find Open Source Projects
If you go to GitHub.com you will see a Navigation Bar at the top with the option to Search GitHub.
This is where you want to enter your typo of choice. In this example, we are going to go with “lenght”. Type it in the search box and hit return.
This will take you to the search results, which should look something like this:
At the top, you will see different ways that you can sort the results. The default is by Repository. We want to view the results by Code, so click on that.
Remember when I told you that coding mistakes were more common than you might think? As you can see, there are over 1.7 million typos just for “lenght” alone!
The search results show the name of the repository on the left and the name of the file containing the error on the right. You can also see that it shows a section of the code and highlights the typo, making it easier to see where the problem is. Now that you have a list of Open Source projects containing the typo “lenght”, it is time to pick a project to contribute to.
I like to change the sort results from “Best match” to “Recently indexed”. You can do this using the drop-down menu on the top right of the search results.
I prefer recent projects because there is a better chance the person maintaining the project will see and incorporate our changes. If a project hasn’t been updated in six months or a year there is a good chance the user isn’t active anymore. No sense wasting time making suggestions to someone who isn’t likely to see them.
For the sake of simplicity, I am going to pick the first one on the list even though it is an older repository.
Making a Pull Request
Now that we know which project we are going to work on, it is time to make a Pull Request to correct the typo.
We want to select the file containing the typo, which, in this case, is the first one – CodeAcademyPrac. Click on that file name and then look for a pencil icon on the right side of the screen.
Clicking that pencil icon will allow you to edit the file. It will also create what is called a Fork, which is a new branch for your changes, leaving the original file untouched.
Make the necessary changes to correct the typo and then scroll down. You will see a Propose file change field. Fill that out with some notes on the changes you made and hit the Propose file change button.
This will finish your fork of the file and take you to a screen where you can compare the changes. In the center of the screen will be a large green button labeled Create pull request.
Press that button and you will find yourself on a screen that shows the previous notes you made about the changes. At the bottom, you will see the green Create pull request button again.
Hit that button one more time to inform the user of the changes you have made and suggest they be incorporated into the main file.
That’s all it takes to contribute to an Open Source project!
You can follow these same steps to help fellow coders find and correct errors in their code. If you upload all your code to GitHub you might even find a fellow coder doing the same for you someday.
One last tip: If we go back to the Unit89487 repository we can see that there is one pending Pull Request.
It is a good idea to check this tab before submitting a Pull Request to make sure there isn’t already a pending request for the same issue.
Hopefully, this article has been a good introduction on how you can start contributing to Open Source projects. If you have any questions feel free to include them in the comment section or hit me up on Twitter.