The first time I learned about open source was through a tweet that promoted Hacktoberfest in 2019. And my first-ever accepted Pull Request was to add a book title in emojis to a list.You might think, "You can't count that as an open source contribution. That's a joke!"I had the same thought myself — until recently. Getting my feet wet in open source was daunting, yet I got through it. And looking back, I learned a ton from that first contribution.As a newbie who didn't know anything about open source, I learned how to communicate with the maintainers, how to work with Git and GitHub, and how to create a pull request. It was a big learning curve!That is one of the reasons why I wrote this guide: to make your journey in contributing to open-source projects smoother and less daunting.In this guide, I'll walk you through the basic Git and GitHub workflow when contributing to open-source projects. I'll also explain how to synchronize your forked and local repositories with the original repository and how to resolve merge conflicts when you encounter one.Without further ado, let's get started!To follow along with this tutorial, you'll need the following:When you're interested in making contributions, you should make sure that the project you're interested in is open source. You can't assume that all projects on GitHub are open source.In this section, I will share what you should check to know if a project is open source.The license is the first thing you want to check. A project on GitHub is not an open source unless it has a license.In most jurisdictions, a project without a license is automatically licensed as "All Rights Reserved" by its owner. It means that no one may use, modify, or redistribute anything in the project without the permission of the owner. If you ignore it, they can legally sue you.You can find the license in a file called LICENSE. You'd usually see in the "About" section of the repository.Most open-source projects are ready to receive contributions when it has a contribution guide. This guide contains everything you should know about how to contribute to the project, from opening an issue to creating a pull request. From the code of conduct to the expected communication style.The procedures and requirements for contributing to open-source projects may differ from one to another. You always want to read and follow the guide when contributing to a project.Usually, you'll find a section about the contributing guide on the README. But if you can't find it there, look for a file called CONTRIBUTING.md or anything similar.Hacktoberfest is a yearly event in October sponsored by DigitalOcean to support open source. To participate in this event, you should check whether a project is involved in Hacktoberfest before contributing.A project participating in the event should have a hacktoberfest topic that you can find tagged in the "About" section of the repository's main page.The project should also have issues that are labeled hacktoberfest. Without this label, then issue is not part of the event, although the repository may have other hacktoberfest topics.So, you're ready to contribute to a repository of your choice. The first thing that you should do is to fork the repository.Fork means creating a copy of a repository in your GitHub account.You always want to fork a repository because most open-source project owners don't authorize contributors to push changes directly to their repositories.By convention, your forked repository is called the origin repository, while the original repository is the upstream repository. I will use these aliases from now on to differentiate them.At the repository's main page on GitHub, click the Fork button at the top right:It will redirect you to the "Create a new fork" form. You can leave the inputs as it is. Then, click the green "Create fork" button at the bottom.This will create a copy of the repository in your GitHub account.After forking the repository, the next thing to do is to clone it.Cloning a repo means creating a copy of a repository in your local environment. You should clone your forked repository when contributing to an open-source project.Here are the steps to follow:Navigate to your forked repository with these steps:Then click on the green Code button. Copy the HTTPS URL by clicking the copy icon.To ensure that you are cloning the forked repository, you should see your GitHub username in the link. For example:That is:In your terminal, run the git clone command along with the URL that you copied:You can navigate to the project's directory with this command:The best practice in open source is to create a new branch whenever you are going to work on an issue. A new branch isolates your changes and keeps the main branch clean.Run this command to create a new branch and navigate to it:Although you can give a branch any name, you should follow conventions related to naming a branch. A branch name usually refers to the change that you make. For example, feature/add-dark-mode or bugfix/broken-link-to-about-page.Now you can start to make changes in your new branch.Let's say you've finished working on changes. Before committing, you must first add them to the staging area.This step allows you to keep your changes while you can still modify them before committing. It also lets you choose which change(s) you're ready to commit.Adding changes to the staging area is often seen as a less critical step. But that's not true. This step allows you to change your mind before committing. Because once you commit your changes, you add a piece of story to the project's history.When you want to add one or multiple files — but not all — to the staging area, run this command:For example:The command above adds the REAME.md and CONTRIBUTING.md files to the staging area.When you add nested files(s) to the staging area, you want to add the path(s) to the file(s). If you can't figure out the exact path, running git status will help give you the status of the files that contain your changes.Here is how to do it:Run git status in your terminal. You will see something like this:Copy the path and run the git add command along with the path(s) to the file(s):Here is an example of adding paths to two files based on the screenshot above:When you want to add all files to the staging area, run this command:This adds all the files with changes to the staging area.To commit means to record your changes. That is why a commit requires a message as the record. Over time, commits will tell the story of the project's history. So, a clear and descriptive commit message is essential.What you should know when committing your changes:To make a commit, run this command in your terminal:Here is an example of a single line commit:And here's a commit with multiple lines:When you are working on changes, there is a possibility that the main branch on the upstream repository has already merged in some pull requests. So, the state of the origin and your local repositories at this time will no longer be the same as the upstream.For this reason, you should always update your local working branch so you'll push the same state as the upstream repository.First, go to the origin repository on GitHub to check if it's up to date with the upstream.You can push your changes when no change exists in the upstream repository.To know if the origin repository is up to date, you'll see a message that says, "This branch is up to date with