Git Course 0%

Code review on GitHub

Intermediate GitHub UI ≈ 10 min

Before this lesson

What you will learn

  • How to batch comments into one review and pick the right verdict
  • How to write a suggestion the author applies with one click
  • What a non-developer can usefully review, and how to say what you checked

After this lesson you can

  • I can review a colleague's pull request usefully, and respond well to a review of mine

Why this matters

You will be reviewed constantly and asked to review more often than you expect: documentation, interface wording, error messages, release notes. The mechanics take five minutes to learn. The manner is what decides whether people want you on their pull requests.

The mechanics

Reviews are written on the Files changed tab. Hovering a line shows a comment icon; clicking it opens a comment box on that line.

Action What it does
Add single comment Posts that comment immediately
Start a review Holds it as a pending comment, visible only to you
Add review comment Adds another to the batch you are building
Review changes → Submit review Posts them all at once with a summary and a verdict
Viewed checkbox Collapses a file you have finished and tracks progress

Prefer Start a review for anything longer than a one-line fix: the author gets one notification instead of twelve, and you can revise a comment before anyone sees it.

The Viewed checkbox is underrated on a large pull request. It collapses each file as you finish it and remembers, so an interrupted review can be resumed rather than restarted, and new commits un-tick the files they touch.

The three verdicts

Verdict Means
Comment Feedback without a judgement; use it when you looked at part of it, or have questions
Approve You are happy for it to merge
Request changes Something must change first; this blocks the merge until you or another reviewer clears it

Request changes is the one to use deliberately. It is right for a factual error or a broken step; it is heavy-handed for a preference, because the author cannot merge until you come back and re-review. For preferences, use Comment and say "non-blocking".

If a review requesting changes is holding up work and its author is unavailable, an Admin can dismiss it with a reason, which is recorded on the pull request.

Suggestions

For anything that is "this word should be that word", write a suggested change rather than a sentence describing it. In the comment box, the suggestion button inserts a fenced block pre-filled with the selected lines:

Markdown
```suggestion
Yes. Trailguide is free for everyone, including commercial use.
```

The author sees a diff and a Commit suggestion button, or can collect several with Add suggestion to batch and commit them together. This is the most useful review skill for documentation work: unambiguous, one click, and the resulting commit credits you as co-author.

Writing a comment that helps

Instead of Write
"This is wrong." "This says 3.9, but the workflow pins 3.12 — should it be 3.12?"
"Reword this." A suggestion containing the wording you mean
"Why did you do it this way?" "What made you choose X over Y? I ask because…"
Twelve separate comments One review, batched, with a summary

Three habits make a reviewer easy to work with. Mark what is optional with "nit:" or "non-blocking:", so the author knows what must change. Say one good thing, briefly; it changes how the rest reads. Review promptly or say when you can, because a pull request waiting two days is a person blocked for two days.

Being reviewed

  • Read the whole review before replying. Half the comments often answer each other.
  • Answer every thread, even with "done" or "kept as is, because…". Silence reads as ignoring.
  • Push fixes as new commits rather than amending, so the reviewer can see what changed since they looked. The squash on merge tidies it anyway.
  • Re-request review from the sidebar once you have addressed everything; that is what returns it to their queue.
  • Resolve conversation on threads you have acted on, if the repository requires resolution before merging.

Reviewing as a non-developer

You are qualified for more than you think, and not for some of it, and saying which is which is the professional move.

You can usefully check Say it like this
Wording, clarity, grammar, tone Just comment or suggest
Whether the docs match what the change does "The code now defaults to 10 but the guide still says 5"
Whether an error message will make sense "A user seeing this will not know what 'nil ref' means"
Whether the change is documented at all "Should this be in the changelog?"
Steps a user follows, by following them "I followed these on Windows and step 3 failed"

For the rest, say so: "I reviewed the documentation only; the Python needs someone else." That is a useful review, and it stops your approval being read as more than it was.

How to do it

Review happens on the platform, but checking out the branch is what makes a documentation review real:

Terminal
$ git fetch
$ git switch docs/12-windows-install-steps

For a pull request from a fork, gh pr checkout 42 fetches it in one step. Following the steps yourself is the most valuable review a writer can give.

Common mistakes

  • Twelve separate comments instead of one batched review.
  • "Request changes" for a preference, which blocks the merge until you return.
  • "Reword this" without saying how. Use a suggestion.
  • Approving without saying what you looked at, which implies more than you checked.
  • Leaving threads unanswered as the author.
  • Force-pushing mid-review, which detaches the comments from the commits they referred to.
  • Reviewing only the diff when the change is a set of instructions. Follow them.

Try it yourself

Goal: give a real review, including a suggestion, and see both sides.

  1. On your practice repository, create a branch with a deliberate typo and a factual error in docs/faq.md.
  2. Push it and open a pull request.
  3. Review it: on Files changed, start a review, add a suggestion for the typo and a comment explaining the factual error, tick Viewed, and submit as Comment.
  4. Switch hats: commit the suggestion, fix the fact, answer and resolve the threads.
  5. Look at the commit the suggestion created and note who it credits.

Expected result: one batched review, one committed suggestion co-authored by the reviewer, and threads answered and resolved.

Show solution

Step 5 is the point. An applied suggestion credits the reviewer as co-author, which is why suggestions are the courteous way to fix someone's wording rather than pushing to their branch. Reviewing your own pull request is artificial, but it is the only way to see both sides of the mechanics in ten minutes.

Check yourself

1. You have five comments on one pull request. What is the considerate way to send them?
2. When is Request changes the right verdict?
3. A wording change is needed on one line. What is most useful?

Key terms

Code review Pull request (PR) Reviewer