Learn how to contribute to open source projects in 7 easy steps (video)

Learn how to contribute to open source projects in 7 easy steps (video)

Last Updated on Nov 27, 2022





This is amir

Today we are going to talk about how to contribute to open source projects

We will go through it together step by step and in the end I have a gift for you

So let’s get started

Step One (Fork)

After you’ve found the project you like the very first step is to fork the project

On github page there is a button on top and you can also see the number of times this project has been forked

When you fork a project, it will create a full copy of the project on your account

So now if I go to my repositories

I can see the forked project in my account as well

So now whatever you change will be completely on your account and the main project won’t be affected

Step Two (Clone)

The next step is to clone the project on your local computer

Now that we cloned the project we run the command

git checkout master

to go to the master branch

If you run

git remote -v

You can see that the remote address is the address to your repository not the original one.

Step Three (Keep Updated)

Open source projects are like live creatures and they are constantly growing and getting lots of updates.

It’s important that your forked project stays updated with the original project.

And to do that a lot of developers add a new remote named upstream and the url for this remote would be the original project

git remote add upstream url-of-the-original-project

And every once in a while they would pull the updates from upstream

Then push the updates to their forked repo

You can do that as well if you want

But I personally prefer to do it from my github account

And This is how:

I would go to the project on github

You see there is a fetch button here

If there is a new update you can click on this and it will update your github repository

And then on my local machine I run

git pull

That’s it. There is no need to add a new remote and pull and push

Github is amazing and has made our lives much easier

Ok let’s continue with our contribution

Step Four (Branch)

Create a new branch by running

git checkout -b issue-update-the-typo

Step Five(Code & Commit)

And then inside this branch you will add your code

Here I only want to change the typo in the file

Then we commit our changes

Here since it’s been only seconds there are no changes. But sometimes you might get a lot of updates.

In that case make sure to go to your github and fetch the updates and pull them on your local computer and your branch

and make sure there are no conflicts between the code you’ve written and the new changes.

Step Six(Push)

Now that you’ve committed all the changes in your new branch you are ready to push it by running

git push origin your-branch-name

Step Seven(Pull Request)

Now if you go to your github account

you will see a compare and pull request button

Here you can see that pull request is for which repository

You could write the description of your pull request

Before you send the pull request make sure to read the contribution guides.

Some projects ask you very specific things for their pull request description

That’s it after you send the pull request the owner will decide if they want to accept it or not.

Sometimes they might send you some comments on editing your code and after that, if they accept it they can merge your code to the main code.

My Gift to You

Now it’s time for my gift to you

When I was starting to contribute to the open source projects I was so scared that I would mess something up and no one would ever let me work with them

and because of this fear I didn’t start contributing to open source for a couple of years.

Now in order to make sure you won’t have the same fear, I have created a repository for you to practice.

Here you can see the guidelines.

All you have to do is to add your name to this file plus a note.

After you send a pull request I will review it and accept it or not.

Key Takeaways

Just a quick recap:

  • We talked about contributing to an open source project on github
  • We forked the project
  • Then we cloned it on our local machine
  • Then we added a new branch and added our codes
  • Then we made sure our code was updated with the original repository
  • Then we committed our changes
  • And pushed the files to our online repo
  • Then we sent a pull request
  • There is also a project for you on github to practice contribution

Final Words

And finally

if you liked what you learned please like and subscribe

That would be a great motivation to do more videos

If you have any suggestions or questions please leave a comment below and I try to answer them as soon as possible

That’s it

Have a wonderful day.

Link to Video:

You can watch the original video on youtube.

Category: programming

Tags: #git #open source

Join the Newsletter

Subscribe to get my latest content by email.

I won't send you spam. Unsubscribe at any time.

Related Posts