Contributing To Open-Source 101

Ayu is a tech blogger, open source contributor & maintainer, and tech community enthusiast based in the Netherlands. She loves photography and iced coffee!
Search for a command to run...

Ayu is a tech blogger, open source contributor & maintainer, and tech community enthusiast based in the Netherlands. She loves photography and iced coffee!
Great stuff Ayu! A wonderful 101 Guide to making that first contribution πππ
Hi friends π, I've been writing tech blog posts for a few years now. If you don't know me yet, English is my second language. My mother tongue is Indonesian, and I'm also surrounded by Dutch every da

I frequently receive messages from enthusiastic contributors who have completed 2 or 3 high-quality pull requests (PRs) in just 1 month. Theyβre proactive, their work is top-tier, and theyβve handled

A few months ago, I shared a story about building an automated open source portfolio using just my smartphone and an AI assistant while on vacation. My main goal was to stop the "spreadsheet struggle"

Recently, I read Bekah Hawrot Weigelβs blog post, "When 'Local' Went Global: The Pandemic Era of International Communities." As someone active in many online communities, I found it a bit sad, but I agree with her points and think they apply to open ...

Hacktoberfest is almost over. How has your contribution journey been so far? Are you confident about contributing to open source projects, or are you still struggling to find your way? If you're new to open source and still feel overwhelmed, that's c...

Hello Fellow CodeNewbies π,
It's the last week of Hacktoberfest!
It's two days left by the time I'm writing this π.
If you are thinking of contributing, you still have time!
Last year, I wrote an article about how I contributed to open-source for the first time.
At that time, I needed to configure the remote repo that points to the upstream. I also had to fetch and merge the upstream from the command line to update the origin repo.
But now, some things are becoming simpler with some GitHub features.
In this article, I will walk you through the flow in contributing to an open-source project.
Without further ado, let's do this! πͺ
π Note on tools: I'm using GitHub site on browser and integrated bash terminal on VSCode.
First, we want to fork the original repo and not clone it right away.
Why do we want to fork the repo? You can find the answer in this article.
How to do this?
Go to the open-source's repo
Fork the repo by clicking on the "Fork" button on the right top of GitHub.

This forked repo is the origin repo, while the original is the upstream repo.
Go to our repo list and open the forked repo.
Click the green "Code" button.
Choose from where we want to clone it and copy the link.

Open terminal/command line.
Direct it to the directory where we want to store the local repo with the cd command.
Run git clone <copied-link>.
We have the local repo, and we are ready to work on our changes.
But before doing so, we need to create a new branch to work on it. Don't make any changes in the main/master branch.
We can name our branch anything we want. For this example, I will call it working-branch-name.
git checkout -b working-branch-name.working-branch-name and will direct us automatically to the branch.There are times when we haven't finished making our changes, and we want to continue working on it later on.
In other words, we are not ready to commit our changes.
Don't leave our work unsaved.
If we don't save or commit our changes, these changes can get carried onto other branches.
So what should we do?
Run git stash.
This command will save our changes and put the file in its original state just as before we make any changes.
Run git stash pop.
This command will give back our saved work, and now we can continue to work on our changes.
However, we are encouraged to commit our changes as soon as we make some changes. It will benefit us to have a history of our changes to look back to.
git add .Alternatively,
Run git add -p.
We can pick which changes we want to stage, one by one. This command will display hunks of the file diff and ask us to stage them one by one.
You can read more about it here.
Run git commit -m "Our message of changes here".
We need to ensure that our original and local repo has the same update as the upstream before the push.
Go to our forked repo on GitHub.
We will see a Fetch upstream button on the right side.

GitHub makes it easy for us to fetch the updates from the upstream.
Click this button, and we will get a dropdown menu.
When the Fetch and merge button is in inactive mode, there is no update on the upstream. If it's green, click it.
Our origin repo now has the same updates as the upstream.
Go to our terminal.
Go to our local main branch with the git checkout main command.
Run git pull.
This command will fetch and merge the changes from the main branch at the origin repo to the local main branch.
Run git status.
This step ensures that our local main branch is up to date with the main branch in the origin repo.

Our local main branch now has the same updates as the origin and upstream.
Go to our branch with git checkout <branch-name>.
Run git merge main.
You can read question no. 5 in this article if you get a conflict after merging a branch.
original repogit push -u origin working-branch-name.working-branch-name to origin repo.Go to the upstream repo.
Click the "Compare & pull request button".

It will redirect us to the "Open a pull request" form.
Fill the form with our changes as the title. Write the description of the changes in the body. Include here a reference to the issue as well.
If we need some reviews from the maintainers before merging, we can make a draft of a pull request.
Click the arrow beside the "Create pull request" button to do this. It will give us the dropdown menu. Select the "Create draft pull request" and click the button. Otherwise, click the default "Create pull request" button.

There is no next. That's it!
You've contributed to an open-source! π
Now you can wait for the maintainers to review your pull request π.
Thank you for reading!
Last but not least, you can find me on Twitter. Let's connect! π