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.
- Click the Pull requests tab in the repository
- Click New pull request
- Select base:
main, compare:add-profile - Scroll down to see the diff
- 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
- 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.
- Click the Files changed tab
- Hover over a changed line — a + button appears
- Click it and enter a comment:
Nice addition of the name field! How about adding more interests?
- 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.
- Go back to the Conversation tab
- Click the green Merge pull request button
- Click Confirm merge
- 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.
- Edit
README.mdon theadd-profilebranch (or a new branch). - Create a Pull Request with a title and description.
- Go to the Files changed tab, review the changes, and leave a comment.
- 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