CodeNewbie Community

Cover image for Contributing To Open-Source 101
Ayu Adiati
Ayu Adiati

Posted on • Originally published at

Contributing To Open-Source 101

Hello Fellow CodeNewbies 👋,

It's the last week of Hacktoberfest!
In fact, it's 2 days left by the time I'm writing this 😄.
If you are thinking to contribute, 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 more simple with some features from GitHub.

In this article, I will walk you to contribute to an open-source.
But before we start, I suggest you read my articles about the ethics in contributing to open-source.
It would help you understand that there are ethics we need to keep when contributing to open-source.

Without further ado, let's do this! 💪

🛠 Note on tools:
I'm using GitHub site on browser and integrated bash terminal on VSCode.

1. Fork the original repo

First of all, 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 repo is the upstream repo.

2. Clone the fork 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>.

3. Create work/feature branch

Now we have the local repo, 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.

  • Run git checkout -b working-branch-name.

    This command creates a new branch with the name of working-branch-name and will direct us automatically to the branch.

4. Make the changes...

We haven't finished making changes, but we want to call it a day

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 will save our changes and put the file in its original state 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.

We've finished making changes

  • Run git add .

    This will add all changes that we made.


  • 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".

5. Update our remote and local repo

We need to make sure that our original and local repo has the same update with 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, it means that there is no update on the upstream. If it's green, click it.

    Our origin repo is now having 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 is to make sure that our local main branch is up to date with the main branch in the origin repo.


    Our local main branch is now having the same updates as the origin and upstream.

    • Go to our branch with git checkout <branch-name>.
    • Run git merge main.

You can read my previous article (question no. 5) if you happen to get a conflict after merging a branch.

6. Push our changes to the original repo

  • Run git push -u origin working-branch-name.

    This command is telling to push working-branch-name to origin repo.

7. Create pull request

  • 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 of the form. 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.

    To do this, click the arrow beside the "Create pull request" button. 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.

8. Now, what next?

drink coffee gif

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

Discussion (0)