DEV Community


Posted on


Git process and commands to know to contribute to an open-source project

With Hacktoberfest happening this month, everyone is so pumped up to contribute to opensource. The aim of this blog is to give you the detailed steps to follow and commands to use when you contribute to an open-source project.

When you find an open-source GitHub project to which you want to add a feature or fix an issue, you would find that you would have to make a pull request(PR) to them to review and accept your changes.

This is the basic workflow to create a pull request.
Fork -> Clone -> Create branch -> Add -> Commit -> Push -> Create Pull Request

We will see it in detail.

  1. Fork the Git repository - This is to create a copy of the original repository in your account. Fork the repository
  2. Once it is done, you will be able to see that repository in your account. Now click Clone/Download and copy the URL.
    Get the Cloning url

    Make sure you are cloning the repository that is in your account by checking the URL. It should have your GitHub username

  3. Open your terminal and navigate to the parent folder for your project and execute the below command with the copied URL.

    git clone <clone-url>

    This will create the project folder with all the content.

  4. Navigate into the project folder.

    cd your-project
  5. Create a feature branch for the changes you are going to make. Make sure the branch name implies the changes you are going to make/feature you are going to add. eg: git checkout -b fixing-border-issue (or) git checkout -b new-product-page-ui

    git checkout -b branch-name
  6. After making the changes, add them to the branch.

    git add file-name
    #To add all the changed files
    git add .
  7. Commit the changes. Give proper comments explaining the changes made.

    git commit -m "your comments"
  8. Push the changes to the branch.

    git push origin branch-name
  9. Once you pushed, go to your GitHub repository page. You should be able to see a yellow bar with Compare and Pull request button. Click that and add comments.

    Pull Request Yellow bar on your repo page

  10. Check and add more comments. When you are sure, Click Create pull request button.

    Create Pull Request

    Pull Request done

  11. You have made a pull request. Now you have to wait till a reviewer merges your PR. You will see a notification once your PR is accepted and merged.

    Pull request merged

Happy hacking!

Top comments (7)

davjvo profile image
Davmi Jose Valdez Ogando

Thanks for the very much needed guide

t00m profile image
Tomás Vírseda

Thank you! Very useful!

Do you have in mind to write another article from the reviewer side?

bhuvanaguna profile image

Not yet! Will write one soon! Thanks for the suggestion. Happy to know that this blog was useful to you!

seokjeon profile image
Se-ok Jeon

Thx for this! This is really what I wanted. Helped A LOT.
Can I translate in Korean this post? If you don't mind, I wanna share this awesome post in Korean. Surely, There will be a linke directing to this original post.

domthewop profile image
𝔻𝕠𝕞𝕖𝕟𝕚𝕔 𝕄𝕖𝕣𝕖𝕟𝕕𝕒 Ⓜ

Consider adding squash to this already-excellent tutorial. :)

bhuvanaguna profile image

Thanks for the suggestion. A new blog with squash and rebase is in progress!

muth0mi profile image
Oliver Muthomi

This is so straight forward. Thanks for the guide.