Skip to content
Tutorials Center
My learning

Topics

Lesson 12 of 36 ยท Pull Requests and Reviews

Reviewing Pull Requests

Review code on GitHub: line comments, suggested changes, approve, comment or request changes, resolve conversations, re-request review, and what makes a review useful.

A code review has two jobs: catch problems before they reach users, and spread knowledge about the code. GitHub's review tools are built into the Files changed tab of a pull request. This lesson covers both sides of the exchange: how to review someone else's work, and how to respond when your own is reviewed.

Getting a review

On a pull request, use Reviewers in the sidebar to request reviews from people or teams. If the repository has a CODEOWNERS file, the right people are requested automatically (see Branch Protection and Rulesets). Reviewers get a notification; the PR shows a yellow dot until they respond. You can also assign a PR to someone, which means "this is the person responsible for getting it merged", a different idea from reviewing.

Reading the diff

Open the Files changed tab. Useful controls:

  • Split or unified view, and the gear menu to hide whitespace changes.
  • The file tree on the left, with a filter, and a checkbox on each file (Viewed) to track what you have read. Marking a file viewed collapses it, and GitHub un-marks it when it changes again.
  • Expand context above and below a hunk with the arrows.
  • Pull request commits: the dropdown at the top lets you review one commit at a time, useful when the story is told in commits.
  • Click a line number (or drag over several) and the blue + icon to comment on that line or range.

Leaving comments

Click + next to a line and write. You then have two choices:

  • Add single comment posts immediately and notifies the author straight away.
  • Start a review (recommended) queues the comment as pending. You keep reading, add more, and submit everything together. The author gets one notification, not twenty.

Comments support Markdown, mentions (@ada), issue links (#12), emoji reactions, and file attachments. A reply forms a conversation that can be marked Resolved once settled.

Suggested changes

For small fixes, click the ยฑ icon in the comment toolbar. GitHub inserts a suggestion block containing the current line, and you edit it:

MARKDOWN
```suggestion
const total = items.reduce((sum, item) => sum + item.price, 0);
```

The author sees a Commit suggestion button. One click commits the change to the PR branch with you credited as co-author, and several suggestions can be batched into one commit. This is far faster than describing a typo fix in words.

Submitting the review

When you finish, click Review changes and write an optional summary. Then choose one of three outcomes:

Choice Meaning When to use
Comment General feedback, no explicit decision Questions or partial thoughts
Approve You are happy with the change It is ready to merge as far as you are concerned
Request changes Problems must be fixed first Bugs, missing tests, design concerns; this can block merging if the repository requires approvals

The PR timeline records each review. If the author pushes fixes, they use Re-request review (the circular arrow next to your name), and you look at just what changed since your last review: GitHub shows a "changes since your last review" comparison.

If a repository sets Dismiss stale pull request approvals when new commits are pushed, an approval no longer counts after a new commit, and a fresh review is required.

What to look for

A useful review is specific, kind and about the code. Prioritize:

  1. Correctness: does it do what the description claims? Edge cases such as empty input, large input, concurrency, time zones.
  2. Tests: are the important behaviors covered, and would the test fail if the code were wrong?
  3. Design: does it fit the existing structure? Is there a simpler approach?
  4. Security: untrusted input, secrets, permissions.
  5. Readability: names, comments that explain why, no dead code.
  6. Scope: unrelated changes belong in another PR.

Prefix comments so intent is clear: nit: (style, optional), question:, suggestion:, blocking:. Praise good work too, it costs nothing.

JS Stand-in: when can this PR merge?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The important detail the model captures: only each reviewer's latest review counts.

Responding as the author

  • Read the whole review first; do not reply to each comment before you have seen the overall picture.
  • Fix what you agree with, push, and mark the conversation resolved (or leave it for the commenter, depending on team habit).
  • If you disagree, explain your reasoning politely and offer an alternative. A short call can be faster than ten messages; summarize its outcome in the thread.
  • Do not force-push over the commits while a review is in progress unless the reviewers are fine with it; it makes "changes since last review" harder to read.
  • Thank people: reviewing is work.
JS Stand-in: classify review comment prefixes

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why use Start a review instead of Add single comment for each remark?

    Batching avoids a flood of notifications and lets you finish reading before sending.
  2. 2. What happens when the author clicks Commit suggestion?

    Suggestions turn into real commits with one click.
  3. 3. A reviewer first requested changes and later approved after fixes. What counts?

    Only the most recent review state of each reviewer matters.
  4. 4. Which is the best example of a useful review comment?

    Specific, actionable and polite comments help the author improve the change.

Summary

  • Review in the Files changed tab: comment on lines, start a review to batch comments, and use suggested changes for small fixes.
  • Finish with Comment, Approve or Request changes; only each reviewer's latest review counts.
  • Review correctness, tests, design, security, readability and scope; label comments by intent.
  • As an author, respond calmly, push fixes, re-request review and avoid rewriting history mid-review.

Next: Merge Methods and Resolving Conflicts