What Will You Learn on this Page?

On this page, you can access much content about Pull Requests. The aim is to give you all the keys to better understanding the PR concept and how to streamline it to be more productive. Through articles and videos, we will proceed in 3 steps; review the Pull Requests basics, talk about best practices & tips, and aboard the automation and why you should use it. You will certainly read things you already know, but you could be surprised by how much you will learn with this page.

Table of Content

What Is a Pull Request?

Why Should You Use Pull Requests, or Not?

Pull Requests - The Basics

Pull Requests - Best Practices & Tips

Pull Requests Automation

What Is a Pull Request?

A pull request on GitHub is a way to propose changes to a project hosted on GitHub. It is a request to the original project's owner or maintainers to "pull" your changes and merge them into their project.

When you submit a pull request, you are essentially asking the project owner to review your changes, discuss any issues or suggestions with you, and potentially incorporate your changes into their project. A pull request typically includes the changes you've made to the project's code and a description of what you've done and why.

Once you've submitted a pull request, other contributors and project maintainers can review your changes and provide feedback. They may ask you to make additional changes or clarifications. If you are using CI/CD tools, the pull request will also be tested to ensure it will not break the code in your main branch before your changes can be merged into the project. Once all issues have been resolved, the changes have been approved, and the checks passed, the project owner can merge your changes into their project.

Pull requests are a core part of the collaborative workflow on GitHub and are commonly used in open-source software development. They allow contributors to propose changes to a project transparently and collaboratively, and they provide a mechanism for project owners to manage contributions and ensure code quality.

Why Should You Use Pull Requests, or Not?

You should use pull requests on GitHub when you want to propose changes to a project you don't have direct access to or own. Pull requests are a way to suggest changes and collaborate with other contributors on open-source projects or on projects where the development process is managed through a code review process.

Basically, if you're working with other developers on the same project, pull requests sound like a necessity.

Here are some scenarios where pull requests are commonly used:

  1. Contributing to an open-source project: If you find a bug in an open-source project or have an idea for a new feature, you can submit a pull request to propose your changes to the project's owner or maintainers.
  2. Collaborating on a team project: If you're working on a team project, you can use pull requests to review and merge changes made by your teammates. This allows you to maintain code quality and ensure that changes are reviewed and tested before they're merged into the main codebase.
  3. Forking a project: If you want to create your own version of a project, you can fork the project on GitHub and make changes to your own copy. You can then submit pull requests to the original project to suggest changes that you think would be valuable to the project.

Overall, pull requests are a powerful tool for collaborating on code and improving the quality of software projects. They enable open communication and encourage constructive feedback, making them an essential part of the development process for many teams and open-source projects.

Pull Requests - The Basics

Pull requests are a crucial part of modern software development, allowing teams to collaboratively review and merge changes to code repositories.

However, managing pull requests effectively can be a challenge, especially for those who are new to the process. In this part, we will cover all the basics of pull request management.

Whether you're a software developer, a project manager, or just interested in learning more about pull request management, this part will provide you with the knowledge and tools you need to successfully manage pull requests and collaborate with your team. So let's dive in and get started!

How to Create a Pull Request Manually?

Manually creating a pull request on GitHub can be a tedious process, despite the convenience it offers to developers. The multi-step process involves:

  1. Locating the primary repository where you wish to submit the pull request.
  2. Navigating to the branch containing your changes by accessing the branch menu.
  3. Clicking on the pull request button.
  4. Selecting the branch you want to merge into from the drop-down menu.
  5. Completing the pull request title and description fields.
  6. Creating the pull request or saving it as a draft request.

For more information about Pull Requests, you can read our article about Pull Request Automation.

Create Pull Request" Button in GitHub from Draft Request

How to Accept Pull Requests in GitHub?

Follow the following steps to accept a Pull Request in GitHub:

  1. Navigate to the "Pull Requests" section located under your repository name.
  2. Choose the pull request that you want to review from the list.
  3. Click on the "Files Changed" icon on the pull request page to view the changes.
  4. Carefully review the changes and add any necessary comments.
  5. Once you've made your changes, click "Review Changes" to view the overall difference. You can also add a comment summarizing your feedback on the changes.
  6. To merge the changes in the pull request, click on the "Approve" button.
  7. Finally, click "Submit Review" to complete the process.

For further information, read our article about our Best Practices to review PR in GitHub.

Main Benefits of Pull Requests

Ease communication in developers' team

Effective communication is vital between developers, and pull requests provide an excellent means of achieving this.

Service providers such as GitHub or Bitbucket allow software features and fixes to be summarized into identifiable containers, with comments and changes all stored in one place.

This helps to eliminate any miscommunication that might occur through other channels like email. Additionally, using pull requests provides valuable insight into the effectiveness of your team.

Make merge tools accessible

Another advantage of pull requests is that they offer accessibility to merge tools.

Regardless of which service provider you use, a pull request will contain a pointer to the main branch, allowing you to compare the code in your feature or fix branch.

This provides a central location for team members to communicate and track any pushes to that branch.

Historize all the changes

Using pull requests also creates a clear history of changes that have occurred between the main branch and the feature branch.

This allows the team to track progress more easily and ensures that any discussions are recorded and stored in chronological order.

Overall, using pull requests is a highly effective way to streamline communication and improve collaboration between developers.

Main Differences Between Merge Request and Pull Requests

Different platforms may use different terms for the same concept, depending on how they manage projects and handle pull requests. For example, some platforms may use the term "merge request" instead of "pull request".

However, despite the difference in terminology, both serve the same purpose and have the same effect.

For instance, GitHub uses the term "pull request", while GitLab uses the term "merge request". In essence, both terms accurately describe what happens when such requests are made, with the former denoting the beginning of the operation and the latter denoting its end.

However, merging a pull request is a more specific term that directly refers to the final stage of the pull request process, where the actual merge takes place.

Alternatively, if the contributions offered by a pull request are not needed, it can be closed, which is a useful feature to have.

Regardless of the terminology used, the key takeaway is that pull requests/merge requests serve as a valuable tool for collaborating and coordinating changes to a codebase.

Pull Requests - Best Practices & Tips

Pull Request - Our Best Practices

Go slow

Take it slow when starting to use pull requests in your git flow, especially if it's a new concept for your team.

Begin with a trial period, selecting a few experienced developers who understand git and your chosen git tool (such as GitHub), and assign them one fix or feature to test the waters.

Keep it simple

Keep things simple by focusing on just a few matters and keeping the requirements for fixes straightforward.

A feature or a fix at a time

For medium to large projects, it's best to create separate branches for each feature and fix.

This way, you can track and discuss each specific branch before refining and ultimately merging or rejecting it.

On GitHub's "Pull Requests" tab, you can see all pull requests assigned to you, including those that require review or response to comments, as well as those you've been assigned to work on.

Stay aware

Staying informed means accessing other information available, such as opened processes and closed pull request histories. By reviewing project history, you can see discussions and reasons that led to specific code.

Understand your KPI

Additionally, you can view pull requests from specific developers and discover essential metrics related to your project, such as who needed the most assistance, who took the longest to complete specific fixes, and who provided the best-quality feedback.

Our 6 Best Practices to Review Pull Requests on GitHub

6 best practices to review pull requests in GitHub
6 Best Practices to Review Pull Request on GitHub

1. Create a description and a title

Before diving into the 800 lines of code, the reviewer should have a clear understanding of what they are reviewing. A well-crafted description or title can aid in this understanding and set the appropriate context for the review. The following are three essential components to include in a pull request description:

  1. The specific task that this pull request is accomplishing
  2. The approach taken to accomplish the task
  3. The reasoning behind this approach and any potential drawbacks of other approaches

In cases where the code changes involve user interface modifications, you can enhance your review by including videos or images that showcase the working interface. Additionally, if there are complex logic changes, a sequence diagram can be used to assist the reviewer in understanding the changes.

To help reviewers understand the changes and their impact on the codebase, pull request templates such as testing plans or impact can be utilized. A template provides a clear structure for reviewing the changes and evaluating their effect.

2. Include all the files to review in the PR

It's crucial to bear in mind that pull requests don't only pertain to code changes.

Other elements such as documentation and configuration files should also be incorporated.

Including these items in the pull request aids in providing clarity to the reviewer and generates a list of files that they must assess before issuing their feedback.

3. Do not put your ego in it

As a senior developer or reviewer, it's possible to become overly preoccupied with minutiae and begin to excessively nitpick. This behavior is unhelpful for the development process.

It's important to avoid being too dogmatic and instead concentrate on the broader perspective. The aim should be to discover a solution that benefits everyone and enhances the codebase.

When suggesting improvements, it's essential to provide a rationale for your suggestions.

You can link to relevant documentation or articles that explain why your recommendation is superior. This approach assists in justifying your suggestions and making it easier for others to comprehend the reasoning behind them.

4. Add comments and questions

During the review process, it's crucial to communicate with the author.

If you have queries or wish to learn more about a specific change, leave comments.

This is also a chance to express why you appreciate a particular aspect of their work. Effective communication is key to ensuring that the feedback is clear, concise, and understood by all parties involved.

5. Do not merge too soon

It's important to note that knowing how to merge pull requests in GitHub doesn't imply that it should be done hastily.

The merge button must only be used after the reviewers have thoroughly tested and accepted the code changes.

It's crucial to keep the pull request open until all queries and comments have been resolved. Once again, effective communication between the author and the reviewers is vital during the review process.

6. Small Pull Request are the best

The larger the number of lines of code in a pull request, the more time it takes to review.

To streamline the process for the reviewer, it's advisable to keep pull requests brief and centered on a single feature or bug.

If a task is significant, it's better to break it down into smaller pull requests and merge them following review.

Comparing pull requests in GitHub takes a considerable amount of time, especially when the changes are extensive. Additionally, it increases the likelihood of the reviewer missing something important.

Thus, it's best to aim to keep the code changes in a pull request under 500 lines to make reviewing the changes more efficient.

For further information about Pull Requests Review, read our blog article.

Pull Requests Automation

In this part, you will learn how to automate your pull requests but also and especially why you should automate them.

How to Automate Your Pull Requests?

Mergify is a useful tool that simplifies the process of setting up automatic pull request rules in GitHub. Here are some steps you can follow to get started:

1. Define Your Rules

Establish the prerequisites and code standards for a merge pull request.

Mergify offers a list of pre-defined rules to choose from, such as mandatory reviews before merging, and specific commit message conventions.

2. Establish an Approval Rule

Ensure code integrity by establishing specific approval rules.

Define the number of developers required to approve the pull request and who has the authorization to review and approve.

3. Provide a Description and Messages

Good communication etiquette is key to a smooth process.

Fill out the details section of a pull request with related files and changes to guide the reviewer.

Create rules that require the details and message box to be filled before a pull request can initiate.

4. Set Up Mergify

Access Mergify in your repository dashboard and choose the desired repositories for Mergify to access.

5. Enable Automation

With Mergify's automation setup, the bots handle merge pull requests without any further manual action.

Maintainers and developers are notified in real-time of request statuses.

By following these steps, you can simplify the pull request process and increase productivity in your workflow. Check out the complete PR automation article, Mergify's documentation for more information and feel free to modify the setup anytime to fit your needs.

To automate your PRs, install Mergify

Why Automate Your Pull Requests?

The advantages of a GitHub automatic pull request extend beyond saving time and reducing manual input. Development teams also gain the following benefits.

Efficient Peer Reviews

Members can easily provide feedback on changes before initiating a merge request, enabling a streamlined peer review process. By automating multiple small pull requests, developers can leave concise comments, reducing miscommunication. Shorter pull requests also help minimize merge conflicts, enabling faster review and merge times.

Reduced Conflicts

Keeping pull requests small is the best way to minimize merge conflicts. With pull request automation, developers can work on smaller tasks, reducing errors and enabling members to commit to the main repository in smaller increments.

Clear Roles

Assigning each task to a single developer or team establishes clear roles and a deeper sense of code ownership. This person/team oversees the entire process, from merging to code deployment.

Automation Case Studies

Chec out our case studies to know moire about our users workflows and how did they use Mergify automation to scale up!

Mergify and Contra

Mergify and Orca Security

Mergify and Productboard