Git & GitHub · Daily Workflow

Pull Requests

A pull request (PR) asks: “please merge my branch into main”. It is where code gets reviewed before it goes live.

Intermediate 5 min Lesson 10 of 19Shows Git 2.47 and GitHub.com as of 2026. GitHub changes its layout from time to time; button names stay the same.
Before you start:Branches
0/19 in Git & GitHub
On this page · 5 min · Intermediate

Learning objectives#

  • Open a pull request from a branch
  • Read the Files changed tab
  • Review, comment and approve
  • Merge and delete the branch

Explanation#

After pushing a branch, GitHub shows a yellow Compare & pull request banner. Check the direction (base: main ← compare: your branch), write a title and description, add reviewers and create the PR.

The Files changed tab shows the difference: green lines added, red lines removed. Reviewers click a line to comment, then use Review changes to Comment, Approve or Request changes.

When the review is approved and checks pass, click Merge pull request → Confirm merge. GitHub then offers Delete branch. Locally, switch to main and pull to get the merged code.

Even when working alone, PRs are useful: they show exactly what you changed, run your automated checks, and give a clean history of features.

Step-by-step screens#

Drawings of github.com, the Git installer, VS Code and a terminal. GitHub changes its layout from time to time; the button names stay the same. The red numbers match the numbered actions under each picture; names on your computer will differ.

Loading pictures…

Code example: The same flow with the GitHub CLI#

ShellThe same flow with the GitHub CLI Illustrative
gh pr create --base main --title "Add contact form" --body "Adds /contact with validation"
gh pr view --web          # open it in the browser
gh pr merge --merge --delete-branch
git switch main
git pull
Expected output
https://github.com/asha/hello-github/pull/3
✓ Merged pull request #3 (Add contact form)
✓ Deleted branch feature/contact-form

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. gh pr create opens the PR from the current branch.
  2. Reviewers look at it in the browser.
  3. gh pr merge merges and deletes the branch.
  4. Switch to main and pull to get the result.

Real-world use case#

In a group project, nobody pushes to main directly; every change goes through a PR so at least one teammate reads it first.

Common mistakes#

Huge pull requests

Nobody reviews 2,000 lines properly. Keep PRs small and focused.

Forgetting to pull main after merging

Your local main is now behind. git switch main && git pull.

Best practices#

  • Small PRs with a clear description
  • Explain how to test
  • Reply to every review comment
  • Delete merged branches

Remember this#

Compare & pull request.

Files changed = the diff.

Approve → Merge → Delete branch.

Practice exercise#

Your task: After a PR was merged on GitHub, update your local main branch.

Show solution
Shell Illustrative
git switch main
git pull

Mini quiz#

Pull Requests quizMultiple choice Question 1 of 1

In a PR to merge feature/x into main, which is the base branch?

Score so far: 0/0

Want more? Practise all Git & GitHub MCQs · Git & GitHub interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.