Skip to content

How to Create a Pull Request

← Back to Git


πŸ”€ Create a Pull Request

A Pull Request (PR) is a way to merge changes from one branch to another via the GitHub UI.

πŸ“š Features

  • Code Approval: Reviewers can approve or request changes.
  • Discussion: Comment on specific lines of code.
  • Diff View: See exactly what changed in files.
  • Merge Strategy: Delete source branch after merge, squash commits, etc.
  • CI/CD Integration: Block merge until tests pass.

Note: In GitLab, this is called a Merge Request (MR).


πŸ› οΈ Step-by-Step Guide

1. Setup Repository

Create a repo called pullrequest.

Create a file cat.txt with the following content:

1. In terms of development, the first year of a cat’s life is equal to the first 15 years of a human life. After its second year, a cat is 25 in human years. And after that, each year of a cat’s life is equal to about 7 human years.
2. Cats can rotate their ears 180 degrees.
3. The hearing of the average cat is at least five times keener than that of a human adult.
4. In the largest cat breed, the average male weighs approximately 20 pounds.
5. Domestic cats spend about 70 percent of the day sleeping. And 15 percent of the day grooming.

Create File

File List

2. Create Feature Branch

Create a new branch called feature:

Create Branch

3. Make Changes

Add one more line to cat.txt in the feature branch:

1. In terms of development, the first year of a cat’s life is equal to the first 15 years of a human life. After its second year, a cat is 25 in human years. And after that, each year of a cat’s life is equal to about 7 human years.
2. Cats can rotate their ears 180 degrees.
3. The hearing of the average cat is at least five times keener than that of a human adult.
4. In the largest cat breed, the average male weighs approximately 20 pounds.
5. Domestic cats spend about 70 percent of the day sleeping. And 15 percent of the day grooming.
6. I like cats

Updated File

4. Open Pull Request

After pushing changes, you will see a Compare & pull request button. Click it.

Compare

Verify the Source (feature) and Target (master/main) branches.

Comment

Scroll down to verify file diffs, then click Create pull request.

Diff

5. Review & Merge

The PR is now Open. Reviewers can comment and request changes. If changes are needed, push to the feature branch; the PR updates automatically.

To merge, click Merge pull request -> Confirm merge.

Merge Button

Merged Status

Go to the master branch to confirm the changes are merged.

Final View


🧠 Quick Quiz β€” Pull Requests

#

What happens to a Pull Request if you push new commits to the source branch?


πŸ“ Want More Practice?

πŸ‘‰ Start Git Advanced Quiz (20 Questions)


πŸ“¬ DevopsPilot Weekly β€” Learn DevOps, Cloud & Gen AI the simple way.
πŸ‘‰ Subscribe here