Deck 14 - Git + Code Review Mechanics (Evaluator Workflow) (objective)
Goal: evaluate PRs like a senior: read diffs fast, spot risk, write high-signal review comments, and propose safe next steps.
You learn: what/why (under the hood), common traps, and evaluator-grade wording.
Output style: PASS/PARTIAL/FAIL + 2-3 issues + fix approach / review comment.
Mental model: what is a commit?
A commit is a snapshot of your repo + metadata (author, message, parent pointers).
Why: history is a graph; rewriting history changes commit IDs.
Mental model: branch vs commit.
A branch is a movable pointer to a commit.
Why: merging/rebasing moves pointers; commits are the history nodes.
Mental model: HEAD and detached HEAD.
HEAD points to your current branch (or a commit in detached mode).
Detached HEAD means commits are not on a named branch unless you create one.
Mental model: working tree vs index (staging).
Working tree: files on disk. Index: what goes into next commit.
Why: you can stage parts of files; staging defines the commit snapshot.
Mental model: merge vs rebase.
Merge keeps both histories and creates a merge commit.
Rebase replays commits onto a new base, creating new commit IDs.
When to prefer merge vs rebase (practical).
Feature branches: rebase locally to keep clean history; merge/squash when integrating.
Shared branches: avoid rebasing after push unless workflow allows it.
Fast-forward merge (what it is).
If target branch has not diverged, Git can move the branch pointer forward without a merge commit.
Why: linear history.
Squash merge (tradeoff).
Squash combines multiple commits into one.
Pros: clean history; Cons: less granular bisecting and story.
Cherry-pick (what/when).
Cherry-pick applies a single commit onto another branch.
Use for backports/isolated fixes; watch for duplicated changes.
Revert vs reset (critical).
revert creates a new commit that undoes changes (safe for shared history).
reset moves branch pointer (rewrites history) and is risky after push.
Force push safety rule.
Never force-push to shared branches unless explicitly allowed.
If needed, use –force-with-lease to avoid overwriting newer remote work.
Stash (what it is).
Stash stores uncommitted changes temporarily.
Use to switch contexts; prefer small WIP branches over long stash chains.
Bisect (why it matters).
git bisect finds the commit that introduced a bug via binary search.
Small commits and good messages make bisect effective.
Unified diff basics.
+ lines are additions, - lines are removals.
Context lines show surrounding code; reviewers focus on behavior changes.
Review triad: correctness, safety, maintainability.
Correctness: does it work? Safety: edge cases/security/races. Maintainability: can others change it safely?
Perf matters most on hotspots.
What to look for first in a PR (triage).
1) Security/data boundaries
2) Correctness/edge cases
3) Async/race/cancel
4) Maintainability
5) Performance hotspots
6) Style/nits
Lockfiles and dependency diffs (why noisy).
Lockfiles can change many lines for one package bump.
Review intent (which deps) + major version bumps + CI status.
Formatting churn (review rule).
Mass reformatting hides real changes.
Best practice: separate formatting/refactor PRs from behavior changes.
Code owners / required reviewers (concept).
Some paths require domain owners.
Why: reduces risk and enforces ownership/compliance.
What makes a review comment high signal?
1) Impact (bug/security/UX)
2) Evidence (where/why)
3) Recommendation (specific fix/options)
4) Priority (blocker vs suggestion)
Must-fix vs nice-to-have (rule).
Must-fix: correctness, security, data loss, crashes, a11y blockers.
Nice-to-have: refactors, naming, micro-optimizations, stylistic nits.
Blocking comment template.
BLOCKER: <impact>. Evidence: <where/why>. Recommendation: <specific>.</specific></impact>
Non-blocking suggestion template.
SUGGESTION: <improvement>. Rationale: <why>. Optional approach: <example>.</example></why></improvement>