Technology

Forking the repo: Contributing to GitHub projects

Posted by Pixafy Team

Contributing on GitHub | Pixafy

GitHub, the popular Git hosting repository service, is well-known across the world, and as such, is home base for some really awesome projects from developers on almost every continent. Since there are so many projects, you are bound to come across a few you may want to contribute to. However, if you have never contributed to someone else’s repo, it may seem a bit daunting. Many developers are just like you — they’re generally nice folks, and if they are looking for contributors, then they would love to have your help. So how do you go about helping? I’ll dig into how you can properly contribute to GitHub open source projects.

This tutorial assumes you already know how to use Git for version control and GitHub. If you do not, you should get to know the basics before contributing to a project. Be sure to check back soon for Git and GitHub tutorials. 

Where To Start

The first thing is where to even find a project to contribute to. I tend to follow a lot of developers on Twitter so whenever they ask for contributions, I have the jump on it. However, there are times when I want to work on a project and no one has asked for help. In that case, the first thing I do is reach out to the developer once I figure out what I would like to contribute. I then inform them of the type of help I would like to offer. When you do this, I recommend starting small. Maybe fixing a small bug or helping with documentation or unit tests. It may not be what you want to accomplish immediately, but it let’s the repo owner know you are willing to contribute before you fork the repo and add some big feature. It will also save you a ton of time as they may already be working on something similar or not want said feature to exist in the core.

NOTE: Also check for a contributing.md file — many projects have this so you don’t have to contact them directly.

Forking The Repo

Once you have established a connection with the developer(s) who own the repo, the next step is to get a working copy of the code. To do this, simply click the “fork” button on the homepage of the repo on GitHub. This will create a repo under your account that is linked to the original repo. (You must have a GitHub account and be signed in to fork a repo.) You won’t be able to push to the original repo, but once you make your changes you can submit a “pull request.” This will let the developer know you have some changes you would like them to review and merge.

Submitting The Pull Request

To submit a pull request you have to go to the GitHub page for the repo you cloned and click on the pull request tab on the right. Click “New Pull Request” in the upper right corner. This will show the branches for this repo. However, we want to merge code from our repo. To do this, click the “compare across forks” link. Now you should be able to select a branch from your repo to add to the pull request. Make sure to give it a good descriptive title and description about your fix/change/feature and then submit the pull request.

What Happens Then?

Now it is up to the developer to either accept your pull request or not to. The number one thing is not to be discouraged if they don’t accept your pull request. Normally they will give you a very detailed explanation of why they didn’t merge your code, and if they don’t, then it’s probably not a project you should invest effort in anyway. (Again, this is one of the reasons why it’s good to start small.) If they do accept it, then kudos to you! You have just entered the world of social coding!

Conclusion

Now you have the whole wide world in front of you … literally! Find nifty projects and contribute to them, then start some cool projects of your own and let others contribute. You will learn so much. If you would like to get your feet wet, you are free to contribute to any project that I am working on at https://github.com/kkemple.

More Resources

Want to see tutorials on specific topics in Git and GitHub? Share your questions and suggestions below, or tweet us @Pixafy!

Tags