Pull Requests

Course 1 · Ch 7
Pull Requests 101
Making your first PR, understanding review comments, and merging your work on GitHub itself

A pull request (PR) is GitHub's mechanism for proposing changes and getting them reviewed before they land in the main branch. Everything covered in Chapters 4 and 5 — branching, pushing — leads here: a PR is what turns "I pushed a branch" into "this change is reviewed, discussed, and ready to merge."

What a Pull Request Actually Is

Despite the name, a pull request isn't really about "pulling" anything technically new — it's a request asking the maintainers of a repository to merge your branch into another branch (almost always into master or main). It wraps that merge in a conversation: a description, a diff view, comment threads, and a record of who approved it and when.

A PR is GitHub's feature, not git's
Plain git has no concept of a "pull request" at all — it's purely a GitHub (and GitLab, and Bitbucket, under different names) feature built on top of ordinary branches and merges. You could do the exact same merge entirely from the command line with git merge — the PR just adds the review and discussion layer on top.

Making Your First Pull Request

1
Create a branch and make your changes
git switch -c fix/typo-homepage, edit, commit — exactly the workflow from Chapter 4.
2
Push the branch to GitHub
git push -u origin fix/typo-homepage — the branch now exists on GitHub, but nothing has been merged yet.
3
Open the pull request on GitHub
GitHub usually shows a "Compare & pull request" prompt right after a push. Otherwise: Pull requests tab → New pull request → choose your branch as the source.
4
Write a clear title and description
What changed and why — same principles as a good commit message (Chapter 2), but with room for more context, screenshots, or a linked issue.
5
Request reviewers (if working with others)
On a solo project this step doesn't apply — but it's exactly where Course 2's code review chapter and team workflows pick up.
Fix typo in homepage hero heading
Open fix/typo-homepage → master · 1 commit · 1 file changed

Description

Fixes "Welcom" → "Welcome" in the hero heading on the homepage. Spotted while reviewing the live site.

Reading and Responding to Review Comments

Reviewers can comment on the PR as a whole, or on specific lines of the diff. Line-level comments are the most useful — they let a reviewer point at exactly the code they're talking about.

👤 Reviewer
Should this be a constant instead of a magic number? Might be worth naming it for clarity.
if (retries > 3) { ... }
↩ You
Good point — pushed a fix extracting it to MAX_RETRIES.

Responding to feedback the right way

  • Push new commits to the same branch — they automatically appear in the same open PR. No need to close and reopen anything.
  • Reply directly under the relevant comment rather than a general reply, so the conversation stays attached to the specific code it's about.
  • Mark resolved threads as resolved once addressed — keeps the PR readable for anyone reviewing later, including the eventual approver.
  • Disagreeing is fine — explain your reasoning rather than silently ignoring or silently complying with feedback you think is wrong. The discussion thread exists precisely for this.

Merging the Pull Request

Once a PR is approved (or, on a solo project, once you're satisfied with it yourself), GitHub offers three merge strategies — the choice affects what your history looks like afterward, covered in depth in Course 2's branching strategies chapter:

  • Merge commit — preserves every individual commit from the branch, plus a new merge commit tying them together. Most information-preserving, but can clutter history with many small commits.
  • Squash and merge — combines all commits on the branch into a single commit on the target branch. Clean history, but loses the individual commit-by-commit story.
  • Rebase and merge — replays the branch's commits individually onto the target branch with no merge commit at all. Clean and linear, but rewrites commit hashes (relevant once Course 3 covers rebasing in depth).
# After merging on GitHub, clean up locally:
$ git switch master
$ git pull
# Brings the merged change down to your local master
$ git branch -d fix/typo-homepage
# Delete the now-merged local branch (Chapter 4)
A merged branch on GitHub doesn't disappear locally on its own
GitHub offers a "Delete branch" button right after merging a PR — that only removes the remote copy. Your local branch (and the matching local copy on any collaborator's machine) still exists until deleted with git branch -d. Harmless to leave around, but tidying up keeps your branch list from accumulating clutter over time.

Chapter 7 Quick Reference

  • A PR is GitHub's review/discussion layer on top of an ordinary git merge — not a git feature itself
  • Flow: branch → push → open PR → write a clear title/description → (request review) → merge
  • Pushing new commits to the branch updates the same open PR automatically
  • Reply to specific line comments rather than general replies, to keep feedback attached to the relevant code
  • Three merge strategies: Merge commit (preserves all), Squash (one clean commit), Rebase (linear, no merge commit)
  • After merging: pull on your local master, then delete your local branch — GitHub's "Delete branch" only removes the remote copy
  • Next chapter: undoing mistakes — restore, soft reset, revert vs reset, and amend