How to Create Pull Requests and Collaborate Like a Pro

Damian Dąbrowski
3 min readJan 22, 2024

--

GitHub has become an essential platform for developers worldwide, providing a hub for collaboration, version control, and code sharing. One of the core features that facilitate this collaborative environment is the pull request. A pull request is a mechanism for a developer to notify team members that they have completed a feature or fix. It’s a request to review and potentially merge their changes into the main codebase. In this article, we’ll guide you through the process of creating a pull request on GitHub, ensuring you can contribute to projects with confidence and ease.

Step 1: Fork and Clone the Repository

Before you can create a pull request, you need to have a copy of the repository you want to contribute to. You can achieve this by forking the repository, which creates a personal copy under your GitHub account. Once forked, clone the repository to your local machine using Git commands or GitHub Desktop.

Step 2: Create a New Branch

To keep your changes organized and isolated from the main codebase (often referred to as the ‘main’ branch), you should create a new branch. This allows you to work on your feature or fix without disrupting the main codebase. Use the following Git command to create and switch to a new branch:

git checkout -b your-feature-branch

Step 3: Make Your Changes

With your new branch checked out, you’re ready to make the necessary changes to the code. This could involve adding new files, editing existing ones, or fixing bugs. Make sure to commit your changes locally with descriptive commit messages that explain what you’ve done and why.

Step 4: Push Your Changes to GitHub

After committing your changes locally, you need to push your new branch and commits to your fork on GitHub. Use the following Git command to push your branch:

git push origin your-feature-branch

Step 5: Create the Pull Request

Now that your changes are on GitHub, navigate to the original repository you forked from. You should see a notification about your recent push with an option to “Compare & pull request.” Click on this button to begin creating your pull request.

Step 6: Describe Your Changes

On the pull request page, provide a title and a detailed description of your changes. Explain the purpose of your changes, any issues it addresses, and any other relevant information that will help reviewers understand your contribution. It’s also good practice to reference any related issues by number, which you can do by typing `#` followed by the issue number.

Step 7: Review and Submit

Before submitting, review your changes to ensure everything is correct. You can add specific reviewers if you know who should look at your pull request. Once satisfied, click on the “Create pull request” button to submit your changes for review.

Step 8: Address Feedback

After submitting your pull request, other contributors to the project may provide feedback. Be prepared to make additional changes based on their suggestions. This collaborative process can involve several iterations until your changes are ready to be merged.

Step 9: Merge and Celebrate

Once your pull request has been reviewed and approved, a project maintainer can merge your changes into the main codebase. Congratulations! You’ve successfully contributed to the project.

Creating a pull request is a fundamental skill for any developer working with GitHub. It allows for transparent, collaborative, and organized development. By following these steps, you’ll be able to share your contributions with the open-source community or your team members effectively, fostering innovation and progress in your projects.

--

--

Damian Dąbrowski
Damian Dąbrowski

Written by Damian Dąbrowski

Hi, I’m Damian, an Electrical Power Engineer, who loves building AI powered apps.

No responses yet