Github How to Contribute to Open Source

Open source projects are everywhere these days. If you’ve ever wondered how people get started contributing code to open source, this tutorial will guide you through the process of setting up a free Github account and getting your first pull request merged into an existing project.

Contributing to open source projects can help you become a better programmer and help others, but knowing how to contribute your time and skills isn’t always easy. This guide was created for this exact purpose and will teach you the process of contributing in a step-by-step way. Each topic includes links to other relevant guides and topics, making it easy to use as a reference when needed.

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.

Fork the main repository

Forking the repository creates a copy of it in your account. You can make changes and push any code to this fork, without worrying about messing up the original code base. Click on the fork button at the top of the page to create a new fork.

The forked repository will now be available in the “Repositories” section in your account.

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.

Create a feature branch

While making any change to the code, a best practice is to create a new feature branch for the changes we need to make. This ensures that we keep the master branch clean, and are able to simply revert our code or make updates when necessary.

Switch to the directory that was created after you cloned the forked repository:

cd guava

Create a new feature branch with a name that identifies with the changes you are planning to do.

Find mentors and teach others

Working with others on a shared project means you’ll have to explain how you do things, as well as ask other people for help. The acts of learning and teaching can be a fulfilling activity for everyone involved.

 Raise a Pull Request against the main repository

Once you have pushed your code to your forked repository, it’s time to raise a PR against the main repository. Click on the “Pull Request” button to start a new PR.

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.

Address review comments and get your PR merged

The code maintainers will often come back with certain comments around the changes you have made. These could either propose functional changes, or cosmetic changes such as formatting, etc. Once you make these changes, simply push them to your branch and the PR will be automatically updated.

Once the changes are good, a maintainer will merge them to the main repository. Congratulations!!! You are now officially an open-source contributor.

Add the main repository as an upstream to your cloned repository

Many other developers, apart from you, also keep merging their code into the main repository. We need to continuously sync our forked repository with it to get the latest code available.

Your cloned repository is linked to your forked repository. To keep your fork in sync with the main repository, you’ll need to connect them by adding the main repository as an upstream in your cloned repository.

Communicate your intent to maintainers

You should always start by communicating your intent to contribute before you do any actual work. Unless indicated otherwise in the README file, the issue tracker is usually the best place for doing that.

  • If you want to work on an existing issue, check that nobody is assigned to it by looking at the Assignees section. Also check the Linked pull requests section. A linked pull request means somebody is already working on it. Look through the comments to see if someone stated their interest to work on the issue. If everything’s clear, post a comment on the issue to indicate your interest to work on it. That way you’re telling people who might come later that someone’s working on the issue. Also, if needed, maintainers can reply to you with guidance and advice.Screenshot showing the Assignees and Linked pull requests sections.
  • If you want to work on a new feature or a bug that’s not already present in the issue tracker, create a new issue. Make sure to follow the issue template if one is proposed, and clearly express your intent to work on the issue. If it’s a new feature proposition or if the issue requires many changes, make sure to get the maintainers’ approval before you move on to the next step.

Update your master branch from upstream

Once the upstream is set, you can pull in changes that have been done in the main repository by other developers. This updates the cloned repository on your local machine:

Push the master branch to your fork

Once you have all the updates on your local machine, you will need to push them to your forked repository so that it’s in sync with the main repository:

git push origin master

(Optional) Delete your feature branch

Once the feature has been merged into the main repository, it’s no longer needed and can be deleted

Conclusion

This is a community guide to contributing to open source. All of us who use open source software are benefiting every day from people just like you, who give their free time to create and maintain the software that makes modern development possible. Thank you for everything you do!

0 Comments

No Comment.