Pull Request Vs. Merge Request

Choosing a Git management tool is no easy feat. Considering it has a significant impact on your workflows, you need to consider a host of factors to ensure streamlined collaboration when using the tool. 

Pull requests in GitHub and Bitbucket or Merge requests in GitLab are the most often used Git tools that facilitate convenient code review. Despite the different names, these features perform the same git merge command to merge feature branches or forks within the existing code.

This brings us to the next important question: What is the difference between a pull request and a merge request — or better yet, is there any difference?

Let’s find out.

What Is a Pull Request?

A feature specific to GitHub and Bitbucket, pull requests give you an easy, web-based way to submit your code (also known as patches) to the project. Think of it as requesting the project to “pull“ changes from your fork.

You initiate a pull request to start merging new changes in the code to the project’s main repository. Once you inform the project team about your intentions, a pull request allows everyone to discuss and review the suggested changes—sometimes even adding follow-up commits—before finally merging the changes with the base branch.

The Git pull command combines Git merge and Git fetch (it downloads new data from the user’s remote repository, but doesn’t combine it with the working files). In other words, the source code is downloaded, and if this code’s reference is indicated, all changes will be combined.

What Is a Merge Request?

Merge requests are user requests whose final action is to merge the code from one branch to another, which is typically known as the master branch.

Like a pull request, a merge request enables the members to discuss the suggested changes and merges, offer feedback, and potentially add new commits to smoothen the overall process. Interestingly, Git merge requests serve as the foundation of the GitLab version control platform.

Git merge combines changes into a single consistent tree, but it’s just one part of what Git pull does. The latter’s request entails combining changes into one tree, followed by downloading the source code.

Pull Request vs. Merge Request: What’s the Difference?

A Git pull request is the same as Git merge request, with both achieving the same result: merging a developer‘s branch with the project’s master branch or main branch.

The only difference is the side they are used on, meaning GitHub uses the Git pull request and GitLab uses the Git merge request. Both requests encourage collaboration among the members and ask receivers to take a look at the suggested branch merge, followed by giving feedback and adding possible commits. 

Think of it as the web-based version of you telling your project team, “Hey! I’ve been working on this cool thing and want to add it to our shared project. Can you take a look at it? If there are no edits or tweaks, I’ll add it to our main project.“

Therefore, both pull and merge requests collect changes from other branches or forks before merging the changes with the existing code.

Note that in both cases, the request and the command are different. For instance, users can initiate a pull request because they want to execute a Git pull command, and users will submit a merge request when they want to run Git merge.

Understanding the Mechanism Behind Pull Requests and Merge Requests

Pull and merge requests enable developers to make new features or kill bugs without altering the project‘s main code or what users see. They can write and test code changes in a local environment without worrying about it ruining their product.

Here’s the mechanism of both concepts:

  1. The developer creates a fork of the main repository, then clones it onto their local workspace.
  2. They resolve an issue or add a new feature by making the desired changes (or additions) to the code. This takes place in their local environment.
  3. After finishing their new code changes and testing them, the developer pushes the changes back to the fork’s repository that they created at the beginning.
  4. Next, they notify the main repository maintainer to review the developer’s pull or merge request. After the review, the maintainer makes the required comments or requests for edits that need to be made for final approval. 
  5. If edits are needed, it’s sent back to the developer for additional comments, such as changes to code. If no edits are necessary, the maintainer will approve the request.
  6. Upon approval, the developer’s new updates in the forked repository get merged with the main project repository. The product is then finally updated with the developer’s bug fixes or new features and will be visible to the end-users.

Why Pull Requests and Merge Requests Are Important

In addition to being similar, both pull requests and merge requests serve the same benefits to the Git developer team that last throughout the project’s lifecycle.

  • Better access to resources that simplify the software development process. Suppose the request includes a pointer to the main branch. This lets you distinguish and compare codes in your fix or feature branch and merge features and fix branches into your main branch. The fact that the team members get a chance to meet, discuss the fix of each branch, and perform the pushes are other advantages.
  • Access to the entire change history. Developers can see any changes present between the future branch and the main branch. This is an excellent feature to reduce errors because the whole team can see what has changed and when. In addition, all team discussions are recorded and saved chronologically too.
  • Streamlined communication between developers. Pull and merge requests allow you to summarize software fixes and features into easily identifiable containers (example: GitHub). This gives you a centralized place for developers to view changes and leave comments. As everything is stored in a single self-contained tool instead of being dependent on email, text messages, and other communication channels, any chances of miscommunication are significantly lower. Think about it: You may forget to check your email, but it’s unlikely you’ll overlook comments tacked on to commits.

Pull Requests Best Practices

Not harming the project’s code is a crucial principle for every software developer. Keeping this in mind, we’ve compiled a list of a few best practices to keep in mind when reviewing pull requests in GitHub. 

Let’s take a look.

Follow the General Etiquette

When providing receiving feedback, keep the following pointers in mind:

  • Understand that the same problem may have more than one good solution, and yours may not be the best one. Be open to discussing tradeoffs, impacts, and risks to reach a resolution faster.
  • Instead of making demands, prioritize asking good quality questions. Avoid making judgments about the author’s perspective.
  • Always ask for clarification and don’t make assumptions.
  • Avoid selective ownership of code, meaning no “mine“ or “yours.“
  • Be humble and respectful. Encourage a real and professional relationship that doesn’t look forced.
  • Talk synchronously (in person, video calls) if you want to offer an alternate solution or are having difficulties understanding a comment. Once that is done, post a follow-up comment summarizing the discussion.
  • When mentioning colleagues and teams you want to involve in a conversation, always mention why. For example, “@teammember for clarification on this logic. Are there any concerns with this approach?“

Offer Comprehensive Feedback Politely

When you’re looking at your team member’s code, try to understand what has changed and why and how it was changed. 

Here are a few pointers to go about offering feedback:

  • Don’t change the code when reviewing.
  • If you disagree with a comment or suggestion, always think before responding. Take a few minutes before typing your comment.
  • Use a checklist to catch any mistakes, errors, and violations against performance risk, conventions, and other rules and regulations.
  • When asking for a change in code, explain your reasons. Be open to offering ways to simplify or improve code.
  • Be mindful of negative bias in online communication. Use positive language whenever possible instead of neutral language. Using emojis, for one, is a good way to clarify tone.

Accept Feedback With Grace

When you’re on the receiving end of feedback and suggestions, don’t let your ego get the better of you. Always be grateful for the reviewer’s suggestions and handle them with grace.

  • Don’t take feedback personally. Assume the reviewer’s comments are in the best intention. If you find a comment overly aggressive or personal, reach out to the person, asking for the clarification of intent.
  • Explain why the code exists. You can also offer solutions in line with the feedback.
  • Try responding to every comment, and extract changes and refactorings into future tasks and stories.
  • In case of an ongoing debate or any confusion, consider talking virtually instead of in the written word. Always post a follow-up summarizing offline discussions so that everyone can stay in the loop regarding the changes made to the project.

Despite the above best practices, it’s possible for the pull request author and the reviewer to disagree. If handled correctly, this is actually a sign of good dynamics. But what isn’t is having endless discussions or one of the parties overriding the other because of seniority or personal opinions.

Keeping this in mind, it’s better to have a conflict resolution strategy. A good rule of thumb is to have at least two code reviewers, in which case, the majority vote wins.

Git Pull Request vs. Git Merge Request in Summary

The Git pull command is a combination of Git fetch and Git merge, meaning the source code will be downloaded and if the reference of this code is clearly indicated, all changes will be combined. On the other hand, Git merge is only the second part of the process that involves combining the changes into one consistent tree.

Your primary focus would be to improve your software development process. That’s why it’s important to familiarize yourself with the official documentation and understand the proverbial commands that you’ll use when using a specific Git-based platform.

Every company that uses Google Workspace should be using Nira.
Bryan Wise
Bryan Wise,
CIO of GitLab

Incredible companies use Nira