Inspired to start contributing to open source projects on GitHub? Excellent! Here’s an overview and tutorial on how to use GitHub.
GitHub is a hosting site for projects using the git distributed version control system. Software projects use version control systems (VCSs for short) so that people can quickly answer questions like: why was this change introduced? who would be the best person to ask about it? what changed between version X and version Y?
Git is particularly modern and feature-rich VCS (trivia: git was created by Linus Torvalds, the original author of the Linux kernel) and forms the basis of GitHub. Some good resources to learn git and GitHub are the following:
You don’t need to know all ins-and-outs of git to contribute to a project on GitHub. In fact, you can contribute to it using the following quick steps (these suppose that you already have git installed on your machine – refer to the “Set Up Git” link to do this if you haven’t already).
The steps to contribute to a GitHub project are:
- Log in to GitHub (or create an account if you don’t have one already)
- “Fork” the project you want to contribute to – there is “fork” button in the upper-righthand corner of each project (there is a screenshot below highlighting the important actions on the GitHub page). This will create a copy of the project under your account. For example if the project is located under https://github.com/lilly/myblueproject then the fork will be created under https://github.com/yourusername/myblueproject. If want to contribute multiple times to the project, you only have to fork it once.
- “Check out” the fork – the copy (fork) which you created above only exists on GitHub’s servers for the moment. You need to copy it to your local machine so that you can work on it. This is done either visually if you have a visual GitHub client or from the command line: git clone firstname.lastname@example.org:yourusername/myblueproject.git. You can find the url you need to use in the right hand side, towards the middle (where it says “clone URL”).
- Do your changes and test them out.
- Create a new branch on which to commit the changes. Again, you might do this from a GUI client or from the command line: git checkout -b my-changes.
- Commit your changes – don’t forget to commit all the files, even the newly added ones (a frequent mistake is to omit such files since they are not included by default): git add .
- Push your changes to GitHub:git push origin my-changes.
- Go to GitHub and create a pull request by clicking on the green button highlighted in the image below. This will let the originator know about your changes and your intentions to contribute.
- Be patient – most developers work on open source projects in their free time and it might take some time for them to review your changes. They might also request that you change your changes 🙂 before they accept it. There might even be a little bit of back-and-forth while you try to give the changes the form they think is best suited for the project.
After some time your pull request will be merged if you keep at it. Congratulations! You just contributed to an open source project and your changes will make the lives of many people better! It’s worth being an open source developer, isn’t it?