How to Contribute to Open Source?

» My first open source? ๐Ÿค“

Hi there,๐Ÿ‘‹๐Ÿป Today we are going to look into my first open-source contribution and also how you can contribute to open source projects. I am not going to lie, it was such a difficult task to do. But once I figured out how to start, it became a lot easier.

When I first thought about contributing, I got confused regarding where do I start?๐Ÿค” How do I find the correct repository? And how do I create a Pull Request? ๐Ÿ™†๐Ÿปโ€โ™€๏ธ

But Then Of course I did some research ๐Ÿ” and saw various tutorials. But then again trying out something new can be so so so overwhelming. And one day I finally created a pull request. (ps: It wasn’t merged but still.๐Ÿคช) Then I did my second contribution but as they say, “time is precious"โฑ๏ธ, even though my second pull request was correct but someone did it before me, and because of that my second contribution wasn’t merged either.๐Ÿ˜ญ

When I was making the above video, I already have a third pull request created, and before they can merge it; there were some discussion going on.

And Suprise: (MY PR WAS MERGED)๐Ÿค“

» Your first open source contribution ๐Ÿฅ‡

But now what I want to tell you is the process of how to start your 1st ๐Ÿฅ‡contribution.

» Step 1: Find a perfect Repository ๐Ÿ”

  1. So the first step is to search for a repository that is open so you can contribute to it.

  2. And to find the repository to contribute, there’s an amazing repository which I came to know it this: awesome for beginners repo.

  3. This is not the only source. (ps: trust me ๐Ÿ˜‰)

  4. We have another set of links through which we can find the correct repo for our contribution. ps: (I’ll be using short forms; PR = Pull request, repo = repository and so on, cause duh, its too long. ๐Ÿ˜ฎโ€๐Ÿ’จ)

  5. List of sources:

๐Ÿ‘‰๐Ÿป GitHub Explore

๐Ÿ‘‰๐Ÿป Open Source Friday

๐Ÿ‘‰๐Ÿป First Timers Only

๐Ÿ‘‰๐Ÿป CodeTriage

๐Ÿ‘‰๐Ÿป 24 Pull Requests

๐Ÿ‘‰๐Ÿป Up For Grabs

๐Ÿ‘‰๐Ÿป First Contributions

๐Ÿ‘‰๐Ÿป SourceSort

๐Ÿ‘‰๐Ÿป OpenSauced

» Step 2: License and Contribution Guidelines ๐Ÿ“

  1. Now that you have selected a project to contribute to. The next thing that you need to look for is a License. Because A project on GitHub is not an open source unless it has a license.

  2. So first do check their License also they will have a contributing guideline about how you can contribute to their project, so read them first properly. It might take you a few minutes(or hours, yes ๐Ÿซ ) but please do read it first. I got legit overwhelmed by just looking at different projects contributing guidelines. But then I decided on one particular project and stuck to it.

Guidlines

» 3. Step 3: Fork the repo

  1. After you have successfully found a project, and read its License and Contributing Guidelines next step is to fork that repo. And that’s so easy.

  2. Go to the project repo and there you will have a fork button on it. Fork Project

  3. Click on it and it will ask you to name that fork repo, so name it and then click Create a fork and that’s it.

Create Fork

  1. Forking a repository means creating a copy of it in your GitHub account. Why we are forking it because of course, the project owners don’t authorize contributors to directly push the changes to the main or upstream repository.

» Step 4: Clone the forked Repository:

  1. Cloning means we create a copy of a repo in your local environment.

Create Fork

  1. So now that we forked a react repo; search for it in your accounts repository section and there you will have the green code button; click on it and then copy the HTTPS link and then in your terminal type the command:
git clone <repo-name> 
  1. Navigate to the project directory by running the command cd followed by the project name.
git clone <project name> 

» Step 5: Search for an issue to work on:

  1. Go to the project repo and search for the issue in the issue tab.

Create Fork

  1. Every open-source project would have a tag “first-timers-only” or “good first issue” etc.

Create Fork

  1. So go into the labels section and search for the “first-timers-only” or “good first issue” tag.

Create Fork

  1. Once found, click on it and there you will have the issues which are only for beginners. But don’t stop here, select the issue, do research, and then when you understand start making changes to the project that you cloned into your local machine.

  2. IMP: But before that, you should create a new branch; which is also our next step.

» Step 6: Create a New Branch

  1. Whenever we are working on an issue the best thing is to create a new branch.

  2. This will helps keeps the upstream branch (main branch) clean.

  3. To do so; we can run the following command that is

git checkout -b <branch-name>
  1. Branch name = what you want your branch to be called.

  2. And a branch name shouldn’t be anything, please. The branch name should refer to the changes that you are going to make.

  3. Like for example: fix/link-in-about-section or if you are creating a new feature it would be like: feature/add-dark-mode or Something like this.

  4. Now that we have set the branch completely start to make changes in your new branch.

» Step 7: Add changes to the staging area and commit

  1. Once you have made the changes, the next thing is to add the changes to a staging area and then commit them. So to add the changes we have a command
git add .

and then run the command

git status

to check the name of files that have been changed.

and then commit the changes by running the command:

git commit -m "your message"
  1. Sometimes you might be stuck on some issue so what you can do is still commit the changes by running the command:
git commit -m "WIP: Cannot run the test"
  1. Or something like this. WIP = Work in progress.

» Step 8: Update your forked repo with the main/upstream branch.

  1. Before pushing your changes first look at if your origin branch is up to date with an upstream branch or not. And if not, update it first. Because it might be possible that the upstream repo had already merged some pull requests and made some changes.

  2. How would you know if your branch is out of date by going to the repository and then in the sync fork button you will have the following heading (shown in image below): so click on the update branch and once done pull all those changes to update your local repo.

Create Fork

  1. To pull the changes run the following command in terminal:
git pull origin main
  1. And that’s it. Now finally we will push the changes to the origin repository.

» Step 9: Push the changes.

  1. Push the changes to the forked repository or origin repository as it is called.

To push the changes run the command in terminal:

git push origin <branch-name>
  1. Branch name = one that you gave earlier. (Remember?๐Ÿคช)

» Step 10: Create a Pull request:

  1. Go to the origin repo and there you will find compare and pull request (shown in picture below) after you have committed your changes. So click on compare and pull request.

Create Fork

  1. Then you fill out a form to fill up. Different Projects have different templates. So fill that and at the end don’t forget to write a clear description of your changes if you have screenshots of what changes you have made, attach them, and also specify which issue number you have worked on and write Closes #issueNumber.

  2. And at last, click the button, to create a pull request.

  3. And there, Congratulations ๐Ÿฅณ๐Ÿฅ‚ you have made your first pull request. Be proud of yourself. ๐Ÿฅ‡ It’s a good feeling right!?

  4. And Now wait for the repo memvers to ckeck your changes, and if it was perfect, your pull request will be merged and if not, don’t lose hope, it might be possible you did some mistake and that’s perfectly fine. We learn from the mistakes right? ๐Ÿฅน

  5. So improve that and go onto to your next pull request.


And thar’s it for this post. I hope it was helpful. Alright then Ill seeeee youuu in the next one, till then do alot of contribution okay? Bye Bye and happy contributing! ๐Ÿฅฐ