Code review on GitHub

Beginner · 10 min

Review a pull request line by line: batch comments, propose exact edits with suggestions, choose Comment, Approve or Request changes, and respond well.

Before thisPull requestsRebasing a branchForce pushing safely

OrcDev · 10 min

Code review on GitHub

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by OrcDevReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Code review exists to catch mistakes and spread knowledge, so comment on behaviour, risk and clarity rather than personal style a formatter can settle.
  • Start a review to batch your line comments, then submit them together as Comment, Approve or Request changes.
  • A suggestion is a comment containing replacement text that the author can apply as a commit with one click.
  • When you address feedback, add commits or use fixup commits and autosquash, and use git range-diff to show what changed since the last round.
  • Reviews are about the change, not the person: ask questions, say why, and separate must-fix from nice-to-have.

What review is for

Tests tell you whether the code does what its author thought it should. They cannot tell you whether the author’s thinking was right. Review is the human check on that: does the change solve the right problem, is it safe, will the next person understand it?

Review also spreads knowledge. After a review, at least two people know how a part of the system works, which matters on the day the author is on holiday.

The practical consequence is that the useful comments are about behaviour and risk. “This loop re-reads the file on every note” is useful. “I would have named this differently” is usually not, and a formatter or linter can settle layout arguments before a human sees them.

The mechanics

Open a pull request and click Files changed. Hover over a line and click the blue comment icon. To comment on several lines, click the first line number and drag, or hold Shift and click the last one. Type your comment, then click Start a review. Later comments use Add review comment instead.

The point of Start a review is batching. Comments in a pending review are visible only to you until you finish. Without that, the author gets a notification per remark while you are still halfway through reading.

When you are done, click Review changes above the diff, write a summary, pick one of three outcomes, and click Submit review:

  • Comment: general feedback with no verdict.
  • Approve: this is ready to merge.
  • Request changes: this should not merge until the problems are fixed.

Use the Viewed checkbox on a file’s header to collapse files you have finished, which helps on a long diff. It unticks itself if the file changes again.

I could not use any of this. I have no GitHub account where I wrote the lesson, so these labels come from GitHub’s “Reviewing proposed changes in a pull request” page, read on 2026-11-23. That page does not cover resolving conversations or re-requesting a review. Both exist in the interface as buttons on the thread and a control in the Reviewers sidebar, but I am describing them from memory, so check your own screen.

Suggestions

The most useful comment for small fixes is a suggestion. In the comment box, click the suggestion icon and edit the lines inside the block it inserts. It looks like this in Markdown:

```suggestion
  if (text.trim() === "") throw new Error("a note needs some text");
```

The author sees the proposed replacement as a diff and can apply it as a commit with a click. For a typo or a missing check, that removes a whole round trip. It does not replace discussion. If you are unsure, ask a question instead of making a suggestion.

Responding to review

As the author, you have two ways to address feedback.

Add commits. Push fix commits to the same branch. The PR updates and checks run again. It is simple and keeps the review history readable.

Fix up the original commits. If your team wants a clean history, mark each fix as a fixup of the commit it corrects and fold it in. I tried this in a scratch repository with git 2.54. After a branch with two commits, I fixed a typo introduced in the first:

git commit -a --fixup=HEAD~1
git rebase -i --autosquash main

The log went from three commits (a fixup! one on top) to two, with the fix folded into the first. In that run, plain git rebase --autosquash main without -i also worked, but I did not check which Git version introduced that, so keep -i. Because history was rewritten, pushing needs git push --force-with-lease, which refuses if someone else pushed to the branch meanwhile. The reasons are in force-pushing safely.

The cost of rewriting is that the reviewer cannot see what changed between rounds. git range-diff fixes that. Before rebasing, keep a pointer to the old version (git branch before-review), then compare:

git range-diff main before-review add-tags

In my run it listed the first commit as replaced (< and > with different hashes), the second as unchanged (=), and showed the typo fix as the only difference. That is exactly the question a re-reviewer asks. Cheaper alternatives are not to rewrite at all, or to squash everything at merge time, which is the next lesson.

Reviews between people

Tone matters more than it seems, because review is text and text reads colder than speech.

  • Ask before asserting. “What happens if the file is missing?” invites an answer. “This is wrong” invites a defence.
  • Say why. A comment with a reason teaches. A bare instruction does not.
  • Mark severity. Prefix optional points with “nit:” or “optional:” so the author can tell what blocks the merge.
  • Review the change, not the person, and thank people for good work, which costs nothing.
  • Respond quickly. A review waiting two days is a branch two days older, which is the cost described in the trunk-based development lesson.

Reviews can also be required by rule, through branch protection and rulesets, and you can route files to the right reviewers with CODEOWNERS.

What the video covers

OrcDev’s “How Senior Developers Review Pull Requests in 2026” is about ten minutes and was published around February 2026 (YouTube shows “9 months ago”). Its description says it uses real PR examples to show what to check and how to review. I could not read a transcript. That makes it a better fit for the first half of this page (what to look for) than for the click path, which GitHub’s docs describe. The channel is small and its audience is mostly front-end developers, so the examples may lean that way. English is judged from the title and description. CoderDave’s older video on the same click path is linked under deeper.

Where this fits

An approved review leads to a merge, and GitHub gives you three ways to merge, each leaving a different history: merge methods: squash, rebase and merge.

Check yourself

  1. 01Why start a review instead of posting each comment immediately?

    Pending comments stay private until you submit, so the author gets one notification and one coherent set of feedback, not a stream of pings while you are still reading.

  2. 02What are the three outcomes when you submit a review?

    Comment gives feedback without a verdict, Approve says it is ready to merge, and Request changes says it should not merge until the problems are fixed.

  3. 03How does a suggestion differ from an ordinary comment?

    It contains exact replacement text for the lines. The author can apply it as a commit directly from the page, so small fixes need no round trip.

  4. 04The author rebased to fix review feedback and force-pushed. How can you see what really changed?

    Compare the old and new versions of the branch with git range-diff, which matches commits across the rewrite and shows only the differences between them. GitHub's compare view for the force-push helps too.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark