DaleSchool

Collaborating with Pull Requests

Beginner20min

Learning Objectives

  • Create a Pull Request and write a description
  • Leave comments and approve in a PR review
  • Merge a PR and clean up the branch

What Is a Pull Request?

You finished working on a branch. Now you want to merge it into main. Should you just merge it?

In a team environment, you get a review first. A Pull Request (PR) is a request that says "please review my changes and merge them."

Through a PR:

  • Teammates can review the code and provide feedback
  • Automated tests can run
  • The change history is clearly documented

Creating a PR

Create a PR using the add-profile branch from the previous lesson.

  1. Click the Pull requests tab in the repository
  2. Click New pull request
  3. Select base: main, compare: add-profile
  4. Scroll down to see the diff
  5. Click Create pull request

Write a PR title and description:

Title: docs: add profile info

Description:
## Changes
- Added a personal profile section to README
- Includes name, interests, and goals

## How to Verify
Check the "About Me" section in README.md
  1. Click Create pull request

Exploring the PR Page

Here are the main tabs on a PR page.

| Tab | Content | | ----------------- | ----------------------------------- | | Conversation | Comments, reviews, discussion | | Commits | List of commits included in this PR | | Files changed | Changed files and diffs |

In the Files changed tab, click the + button to the left of a line number to leave a comment on a specific line.

Leaving a Review

Here is how a teammate reviews a PR. When practicing solo, review your own PR.

  1. Click the Files changed tab
  2. Hover over a changed line — a + button appears
  3. Click it and enter a comment:
Nice addition of the name field! How about adding more interests?
  1. Click Add single comment or Start a review

Review statuses:

  • Comment: General feedback (does not block merge)
  • Approve: Approved — ready to merge
  • Request changes: Changes needed — cannot merge until addressed

Merging a PR

Once the review is complete, merge.

  1. Go back to the Conversation tab
  2. Click the green Merge pull request button
  3. Click Confirm merge
  4. Click Delete branch (clean up the merged branch)

Your changes are now in the main branch.

"Why?" — How PRs Improve Team Quality

A PR is more than a merge request. It is a team's knowledge-sharing channel.

  • Reviewers catch bugs early
  • Code style and design direction stay consistent
  • New team members learn the codebase by reading PRs
  • "Why was it written this way?" — the PR description has the answer

Many teams enforce a "no direct commits to main" policy. Every change must go through a PR.

Deep Dive

Draft PR — When you are not ready for review yet

Use a Draft PR when you want to share work in progress but are not ready for a review.

Select Create draft pull request when creating a new pull request.

In draft status:

  • Others can view and comment on the code, but the merge button is disabled
  • When ready, click Ready for review to convert it

It is a great way to signal "work in progress" to your team.

Setting Up a PR Template

Adding a PR template to your repository auto-fills the description format when creating a PR.

Create a .github/pull_request_template.md file in the repository root:

## Changes

<!-- What did you change? -->

## How to Test

<!-- How did you verify? -->

## Related Issues

<!-- Closes #issue-number -->

This ensures everyone on the team writes consistent PR descriptions.

  1. Edit README.md on the add-profile branch (or a new branch).
  2. Create a Pull Request with a title and description.
  3. Go to the Files changed tab, review the changes, and leave a comment.
  4. Merge the PR and delete the branch.

Q1. What is the main purpose of a Pull Request (PR)?

  • A) To copy and retrieve a repository
  • B) To request that teammates review and merge branch changes
  • C) To upload files to a remote server
  • D) To switch a repository to public

Further Reading