DEV Community

Cover image for Open source Contribution, First Pull Request
Idrissa HEMEDY for Kali Academy

Posted on

Open source Contribution, First Pull Request

Introduction

As newcomers to web development, we often believe that the only way to improve our skills is by working on our own projects. But what happens when you run out of project ideas or don't have a team to collaborate with? Should you close your code editor and put your ambitions on hold? This is where Open Source Contributions can make a significant difference. By contributing to open source, you not only hone your coding skills but also become part of a global community that builds and maintains software used by millions. Whether it's your first pull request or your hundredth, open source offers endless opportunities for learning, collaboration, and growth.

What is an Open source Contribution?

An open source contribution refers to the act of participating in the development or improvement of open source software. Open source software is software that is freely available for anyone to use, modify, and distribute.

Open source contributions are typically made through platforms like GitHub, where developers can submit changes via pull requests that are reviewed and potentially merged into the main project by the maintainers.

What can I contribute on?

Contributions can come in various forms, including:

  • Code Contributions: Writing new features, fixing bugs, or improving existing code.
  • Documentation: Creating or improving documentation to help others understand how to use the software, how it works, or how to contribute.
  • Design: Contributing to the visual design, user interface, or user experience of the project.
  • Testing: Writing tests, reporting bugs, or helping to ensure the software works as intended across different environments.
  • Translation: Translating the software and its documentation into different languages to make it accessible to a broader audience.
  • Community Support: Helping other users and contributors by answering questions, providing guidance, or reviewing pull requests.

Open source project ideas

Here is some beginner friendly open source projects you can look on:

  1. First Contributions
  2. EddieHub Community
  3. Public APIs
  4. Habitica
  5. Exrecism

Pull Request

As discussed earlier, pull requests (PRs) are the primary method developers use to submit their changes to open source projects. When a developer opens a PR, it signals to the project maintainers that new code is ready for review. The maintainers carefully evaluate the PR, ensuring that the changes contribute value to the project without introducing any issues or breaking existing functionality. If the PR meets these criteria, it is merged into the main codebase, becoming part of the official project.

Step by Step guide to your First PR

We assume that you are already familiar with Git and GitHub, and have them set up on your machine. If not, refer to this article on how to install Git on Windows and How to set it up.

Once you have everything set up and have chosen the project you want to contribute to, follow these steps to make your first PR

1. Create a copy of the repository

A repository, or "repo," is essentially the main folder where a project is stored on GitHub. To start working on an open-source project, you first need to create your own copy of the repository. This process involves forking the repository to create a copy under your GitHub account and then cloning it to your local machine, giving you a working version of the project that you can modify and experiment with.

a. Forking
When you’re on the main page for the repository, a Fork button will be displayed on your upper right-hand side of the page, underneath your user icon:

Image description

Follow the process and end with the forking.

b. Cloning
You can copy the URL by using the green “⤓ Code” button from your repository page that you forked from the original repository page. Once you click the button, you’ll be able to copy the URL by clicking the clipboard button next to the URL. Open your terminal. navigate to the folder you want to clone the project to and clone it using this Git command:

git clone --copied-link
Enter fullscreen mode Exit fullscreen mode

After that, navigate to the cloned folder by taping:

cd cloned-project
Enter fullscreen mode Exit fullscreen mode

2. Create new branch and start modifications

Before you begin working on the code and making changes, it's important to create a new branch. This branch will serve as a separate workspace for your code modifications, keeping them isolated from the main codebase. Your changes will be saved and reviewed on this branch before they are potentially merged into the project. To create a new branch and switch to it, open your terminal and enter the following command:

git checkout -b --your-branch-name
Enter fullscreen mode Exit fullscreen mode

🎉 You're done. You can now make changes and save them.

3. Save local changes and commit

After working on your changes, you'll need to save them locally by doing:

git add -A
Enter fullscreen mode Exit fullscreen mode

And then commit your changes:

git commit -m "Custom commit message"
Enter fullscreen mode Exit fullscreen mode

4. Update local repository

When working on a project with other contributors, it’s crucial to keep your local repository up-to-date to avoid conflicts when making a pull request. To do this, you need to sync changes regularly.

First, we'll cover how to configure a remote for your fork, then how to sync it with the original repository

a. Configure a remote
Let’s first check which remote servers you have configured. From the directory of the repository in our terminal window, let’s use the git remote command along with the -v flag to display the URLs that Git has stored along with the relevant remote

git remote -v
Enter fullscreen mode Exit fullscreen mode

Next, we’ll specify a new remote upstream repository for us to sync with the fork. This will be the original repository that we forked from. We’ll do this with the git remote add command

git remote add upstream --original-repo-link
Enter fullscreen mode Exit fullscreen mode

We can verify that our remote pointer to the upstream repository was properly added by using the git remote -v command again from the repository directory.

b. Sync the fork
To sync our fork, from the directory of our local repository in a terminal window, we’ll use the git fetch command. Since we used the shortname “upstream” to refer to the upstream repository, we’ll pass that to the command:

git fetch upstream
Enter fullscreen mode Exit fullscreen mode

Now, commits to the main branch will be stored in a local branch called upstream/main.

Let’s switch to the local main branch of our repository:

git checkout main
Enter fullscreen mode Exit fullscreen mode

And merge our changes:

git merge upstream/main
Enter fullscreen mode Exit fullscreen mode

Your fork’s main branch is now in sync with the upstream repository, and any local changes you made were not lost.

5. Create a PR

At this point, you are ready to make a pull request to the original repository.

You should navigate to your forked repository, and press the New pull request button on your left-hand side of the page.

Follow the steps and there we go, your first Open source Contribution is live and you achieve your first PR.
🎉🎉 Congratulations.

Conclusion

Contributing to open source through your first pull request is a rewarding experience that accelerates your growth as a developer. It’s not just about improving your coding skills, but also about collaborating with a global community, learning best practices, and making a meaningful impact. By following these steps, you’re not just submitting code—you’re joining a movement that powers countless projects around the world. Dive in, contribute, and watch your skills and confidence soar.

Top comments (1)

Collapse
 
jjbb profile image
Jason Burkes

Thanks for the detailed guide! Just curious, how do you suggest picking which open source project to contribute to for absolute beginners? Any tips for evaluating if a project is beginner-friendly?