How to Contribute to Open Source Project

Smruti Ranjan Sahoo - Nov 15 '20 - - Dev Community

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!!

.