Creating and Managing Pull Requests (PRs) on GitHub0%

Creating and Managing Pull Requests (PRs) on GitHub

Beginner12 min read•Updated: Jul 11, 2026
Study MaterialsCheatsheet

Creating and Managing Pull Requests (PRs) on GitHub

The Pull Request (PR) is the foundational collaboration workflow of modern software engineering. It is how developers propose changes, invite teammates to review code, run automated tests, and safely merge features into production.


1. What is a Pull Request?

A Pull Request is not a Git command—it is a feature popularized by GitHub. When you create a Pull Request, you are literally asking the maintainers:

"I have finished developing feature X on branch feature-auth. Would you please pull my commits into your main branch?"
Output
Your Branch: (C1) ---> (C2) [feature-auth]
|
[ Pull Request ]
|
Target Branch: (C1) <---------------+ (main)

2. The Complete Pull Request Workflow

Professional software teams follow this 6-step PR cycle daily:

Step 1: Create a Focused Feature Branch

Never write code directly on main:

Bash / Terminal
git switch main
git pull
git switch -c feat-stripe-checkout

Step 2: Develop, Stage, and Commit

Write your code and create semantic commits:

Bash / Terminal
git add src/payments/stripe.js
git commit -m "feat(payment): integrate Stripe checkout session API"

Step 3: Push the Branch to GitHub

Bash / Terminal
git push -u origin feat-stripe-checkout

Step 4: Open the Pull Request on GitHub

  1. 1
    Navigate to your repository on GitHub.
  2. 2
    A yellow notification banner will appear: "feat-stripe-checkout had recent pushes... Compare & pull request". Click it!
  3. 3
    Select the base branch (main) and the compare branch (feat-stripe-checkout).
  4. 4
    Write a descriptive Title and Description:
  • What problem does this solve?
  • What approach did you take?
  • How can the reviewer test it?
  1. 1
    Click Create pull request.

3. Writing an Exceptional PR Description

A high quality PR description accelerates code reviews and prevents misunderstandings. Industry-standard PR template:

Markdown
## Summary
Integrates Stripe checkout API to allow customers to pay for course subscriptions online.
 
## Changes Made
- Added `stripe` npm dependency.
- Implemented `/api/checkout` endpoint with Webhook signature verification.
- Created checkout modal in `src/components/CheckoutModal.jsx`.
 
## How to Test
1. Run `npm install` and `npm run dev`.
2. Navigate to `/courses/python-for-beginners`.
3. Click "Enroll Now" and verify test card numbers succeed.
 
## Closes
Closes #42
Pro Tip
[!TIP] Writing keywords like Closes #42 or Fixes #15 in your PR description tells GitHub to automatically close the associated issue when the PR is merged!

4. Merging Options on GitHub

When a PR is approved by reviewers and passes all CI/CD checks, maintainers have three merge strategies available:

Output
[ Merge pull request ] v
--------------------------
1. Create a merge commit : Creates a 3-way merge commit preserving all commits and branch context.
2. Squash and merge : Combines all commits into a single clean commit on main (keeps main history spotless!).
3. Rebase and merge : Re-applies commits linearly without a merge commit.

Interactive Quiz

Practice Quiz

Question 1
What is the primary purpose of a Pull Request (PR) on GitHub?
Question 2
When creating a Pull Request, what is the "base" branch?
Question 3
What happens when you include the phrase Fixes #104 in a GitHub Pull Request description?
Question 4
What does the "Squash and merge" option do when merging a Pull Request?
Question 5
What is a "Draft Pull Request" on GitHub?
Next Lesson

Code Reviews, Inline Comments, Approvals and Changes Requested

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext