DEV Community

Cover image for How to Contribute to Open Source Project
Smruti Ranjan Sahoo
Smruti Ranjan Sahoo

Posted on

How to Contribute to Open Source Project

Opensource.com asked readers a few months ago: What’s the biggest barrier to participation in open source? Answers from 56% of poll takers were that they aren’t sure where to start. And, 13% said they are uncomfortable jumping in.

If you feel the same way, this post is for you.
If you know Github and know its commands but not sure how to check out the project and make some changes, then this post is also for you.

What Is Open Source?

Open-source software has a few key characteristics:

  1. It’s free to use
  2. The source code is accessible
  3. Developers are free to modify the source code for their own purposes, including for commercial use

This article for beginners makes their first contribution. If you are looking to make your first contribution, follow the steps below.

0. Make a GitHub account

Most open-source projects are hosted on GitHub, which is a website for sharing and saving code. Anyone can make a GitHub account for free. Paid accounts are only necessary if you want some of your code to be private.

1. Choose a project and issue to work on

A set of files for a project is called a Repository, and Issues are where people ask for help fixing things.

2. Fork the repository

Fork the repository by clicking on the fork button on the top right of the page. This will create a copy of this repository in your account.

3. Clone the repository

Now clone the forked repository to your machine. Go to your GitHub account, open the forked repository, click on the code button, and then click the copy to clipboard icon.

Open a terminal and run the following git command:
git clone "url you just copied"
where “URL you just copied” (without the quotation marks) is the URL to the repository (your fork of this project). See the previous steps to obtain the URL.
For example:
git clone https://github.com/this-is-you/first-contributions.git
where this-is-you is your GitHub username. Here you're copying the contents of the first-contributions repository on GitHub to your computer.

4. Create a branch

Change to the repository directory on your computer (if you are not already there):
cd first-contributions
Now create a branch using the git checkout command:

git checkout -b your-new-branch-name

For example:
git checkout -b alpha

(Here alpha is the name of the branch. You can choose a reasonable name for the branch.)

5. Make necessary changes and commit those changes

Now make any changes to a file in a text editor. Now, save the file.

For example Open Contributors.md file in a text editor, add your name to it. Don't add it at the beginning or end of the file. Put it anywhere in between. Now, save the file.
If you go to the project directory and execute the command git status, you'll see there are changes.
Add those changes to the branch you just created using the git add command:

git add Contributors.md

Now commit those changes using the git commit command:

git commit -m "Add to Contributors list"

Here -m stands for a message. Always add a meaningful message while committing, so that it will be easy for other developers to see what the commit is about.

6. Push changes to GitHub

Push your changes using the command git push:

git push origin

replacing with the name of the branch, you created earlier.

7. Submit your changes for review

If you go to your repository on GitHub, you’ll see a Compare & pull request button. Click on that button.

Now click on the “Create pull request” button. It will submit the pull request.

It will notify the maintainer of the repository and he/she can decide whether to include your changes or not.

Voila !! You did your first contribution.
Happy learning!!

Top comments (7)

Collapse
 
qmenoret profile image
Quentin Ménoret • Edited

If you want help get started, we organise a bi-monthly remote Meetup to help people submit their first PR. If you're use to it, you can also join to help others!
Next edition here
More info here

Collapse
 
szabgab profile image
Gabor Szabo

Nice, I think it would be useful to expand each point into more details.
e.g How do I choose a project? How do I fork a project?

Collapse
 
dhintz89 profile image
Daniel Hintz • Edited

I wrote a post for Hacktoberfest this year with that purpose in mind, meant for complete beginners. It contains a few ways to go about searching in Github and goes over the technical workflow. Check it out here, hope it helps.

@qmenoret - great point in the post you linked about making sure the issue is not already being worked and identifying yourself in the comments - I missed that bit in my post.

Collapse
 
qmenoret profile image
Quentin Ménoret

Another good read with suggestions about this: dev.to/doctolib/make-your-first-pu...

Collapse
 
c99srs profile image
Smruti Ranjan Sahoo

Hey @Gabor, thank you for your great suggestion. Yes, I will consider your points in my next article.

Collapse
 
moonsmile profile image
Nguyễn Minh Tuấn

I think this article is "how to use git repos" :))

Collapse
 
c99srs profile image
Smruti Ranjan Sahoo

Hi @Nguyen, thank you. Yes, it is a combination of how to use a git repo and also how to contribute. Because sometimes people know things, but they are not sure how to contribute using Github. So this article covers that aspect.
I would be happy to consider your point if you have some.