What Is Code Review in Git?

What Is Code Review in Git?

A complete beginner's guide to how teams check each other's code before it ships — what code review actually is, how Git and platforms like GitHub make it possible, and how to do it well.

Imagine you’re editing a shared document with ten other people, and anyone could type directly into the final, published version at any moment — no second pair of eyes, no chance to catch a typo or a factual mistake before the whole world sees it. That’s what writing software without code review feels like. In this guide, we’ll build up the idea of code review piece by piece: what it is, why teams do it, how Git’s branching model makes it possible, what actually happens during a review, and how to give and receive reviews that make software — and the people writing it — better.

1What Code Review Actually Is

Let’s start with a precise, beginner-friendly definition before touching any Git mechanics.

What it is: Code review is the practice of having one or more other people read and evaluate a proposed code change before it becomes a permanent part of a project. Instead of a developer changing code and immediately making it official, the change is paused, shown to teammates, discussed, possibly revised, and only then accepted.

Why it exists: No single person — no matter how experienced — reliably catches every bug, security hole, or confusing piece of logic in their own work. A second reader, seeing the code with fresh eyes and without the author’s assumptions, regularly spots problems the author missed. Code review turns “one person’s best effort” into “the team’s collective judgment.”

Where it’s used: Code review is standard practice at nearly every serious software company and open-source project, from two-person startups to organizations with thousands of engineers. In Git specifically, it’s most commonly organized around a mechanism called a pull request (also called a “merge request” on some platforms), which we’ll unpack in Chapter 3.

Everyday Analogy

Think of code review like an editor reviewing a journalist’s article before it’s published. The journalist did the research and wrote the draft, but the editor reads it with fresh eyes, checks facts, questions unclear sentences, and suggests improvements — all before it reaches the printing press. Code review does exactly this for software: the “printing press” is the main codebase that customers actually run.

Practical example: At a company building a mobile banking app, a developer might fix a bug in how account balances are calculated. Before that fix goes live, a teammate reviews the change, notices the fix doesn’t handle a specific currency-rounding edge case, and asks for it to be corrected — catching a bug that could have caused real customers to see wrong balances.

2Why Code Review Exists: The Problem It Solves

Like most engineering practices, code review grew out of real, expensive failures.

In the earliest days of software development, a single programmer often wrote, tested, and shipped code entirely alone. As teams and codebases grew larger through the 1970s and 1980s, companies noticed a pattern: bugs that slipped into production were disproportionately the kind that a second person would have caught in seconds — a typo in a condition, a forgotten edge case, a security check left out. Formal “code inspections,” pioneered at IBM in the 1970s, showed that structured review by peers caught a large share of defects far more cheaply than finding them after release.

Version control systems like Git made this practice dramatically easier to adopt at scale. Because Git lets a developer create an isolated branch — a separate line of work that doesn’t touch the shared codebase — a team can build a workflow where no code reaches the shared branch without first being reviewed on its own branch. This is the technical foundation that platforms like GitHub built pull requests on top of.

i
Key Insight

Git itself has no built-in “review” feature — there’s no git review command. Code review is a workflow and a set of tools (most commonly pull requests) built on top of Git’s branching model by hosting platforms like GitHub, GitLab, and Bitbucket, plus dedicated review tools like Gerrit.

The core problem code review solves: individual engineers have blind spots, incomplete context, and inconsistent standards. Left unchecked, this leads to bugs, security vulnerabilities, inconsistent code style, and knowledge locked inside one person’s head. Code review distributes both the checking and the knowledge across the team.

3How Git’s Branching Model Enables Review

To understand code review, you first need to understand the Git mechanism that makes it possible: branches and pull requests.

In Git, a branch is an independent line of development — think of it as a parallel copy of the project where you can make changes without affecting the main, shared version (often called main or master). A developer working on a new feature or bug fix typically creates a new branch, makes their changes there, and commits them — all without touching the main branch at all.

Once the work on that branch is ready, the developer opens a pull request: a formal request asking the team to review the changes on their branch and, if approved, merge (combine) them into the main branch. The pull request is the container where the entire review conversation happens.

flowchart LR
    A["Developer creates a branch"] --> B["Commits code changes to the branch"]
    B --> C["Opens a Pull Request"]
    C --> D["Reviewers read the diff and comment"]
    D --> E{"Changes requested?"}
    E -->|Yes| F["Author updates the branch"]
    F --> D
    E -->|No, approved| G["Pull Request is merged into main branch"]
    
FIG 3.1 — The full code review cycle, from branch creation to merge

Step by step, in plain language: first, the author isolates their work on a branch, so nothing they do can accidentally affect the shared codebase yet. Second, they push that branch to the shared remote repository and open a pull request, which automatically shows a “diff” — a side-by-side view of exactly which lines were added, removed, or changed. Third, one or more reviewers read that diff and leave comments, either on specific lines or on the pull request as a whole. Fourth, if reviewers ask for changes, the author makes more commits on the same branch, and the pull request updates automatically to show the new changes. Fifth, once reviewers are satisfied, they formally approve the pull request. Finally, the approved changes are merged into the main branch, becoming a permanent, shared part of the project.

4What Reviewers Actually Look At

A good review isn’t just “does this look okay” — it systematically checks several distinct dimensions of the change.
Correctness

Does It Do What It Claims?

Does the logic actually solve the stated problem, including uncommon or edge-case inputs the author might not have tested?

Design

Is It Structured Well?

Does the change fit sensibly into the existing codebase, or does it duplicate logic that already exists elsewhere?

Readability

Can Others Understand It?

Will a teammate reading this code in a year understand it without needing to ask the original author?

Testing

Is It Verified?

Are there automated tests covering the new behavior, especially the tricky edge cases?

Security

Does It Introduce Risk?

Could this change expose sensitive data, allow unauthorized access, or introduce a known vulnerability pattern?

Performance

Will It Scale?

Does the change introduce something that will slow down significantly as data or traffic grows?

Consistency

Does It Match Team Style?

Does it follow the project’s existing naming conventions, formatting, and architectural patterns?

Scope

Is It Focused?

Does the pull request do one clear thing, or does it bundle unrelated changes together, making it harder to review?

Not every review needs to check all eight dimensions with equal depth — a one-line documentation fix mostly needs a readability check, while a change to a payment system deserves careful attention to correctness, testing, and security. Experienced reviewers calibrate how much scrutiny a change needs based on its risk and size.

5Review Design Patterns & Anti-Patterns

Teams converge on recognizable review “shapes” over time — some healthy, some worth avoiding.

The Small, Focused Pull Request changes one thing, is easy to describe in a sentence, and can typically be reviewed in under fifteen minutes. This is the gold standard: small changes get reviewed faster, more thoroughly, and with fewer misunderstandings.

The Required-Approval Workflow configures the repository so that a pull request cannot be merged until at least one (often two) reviewers have formally approved it. This is the most common safeguard used by teams to make sure review isn’t accidentally skipped under deadline pressure.

The Automated-Checks-Plus-Human-Review Workflow pairs human review with automated checks — tests, linters, and security scanners — that must all pass before a human even needs to look at the change, freeing reviewers to focus on judgment calls rather than mechanical issues like formatting.

The Pair-Programming Alternative is worth mentioning: some teams write code together in real time instead of reviewing afterward, treating the “review” as continuous rather than a separate step. This isn’t better or worse than pull-request review — it’s a different way of getting a second set of eyes on the work.

DECISION — SHOULD A HUGE PULL REQUEST GET ONE BIG REVIEW? Common Pitfall
The Situation

A developer works alone for two weeks and then opens a single pull request containing thousands of changed lines across dozens of files.

Why This Becomes a Problem

Reviewers cannot hold that much context in their heads at once. Research and team experience both show that review quality drops sharply once a change grows past a few hundred lines — reviewers start skimming instead of truly reading.

The Better Pattern

Break large efforts into a sequence of small, independently reviewable pull requests, each building on the last, so every step gets a genuinely careful review instead of a rushed skim.

Common anti-patterns to avoid: the Rubber Stamp (approving without truly reading the change, just to unblock a teammate); the Nitpick Avalanche (burying a pull request in dozens of minor style comments while missing a real correctness bug); and the Silent Reviewer (a reviewer assigned to a pull request who never responds, leaving the author blocked indefinitely).

6Security Considerations

Code review is, among other things, one of the most effective security controls a team has — but only if it’s treated that way deliberately.
!
Warning

Never approve a pull request that adds hardcoded secrets — passwords, API keys, or tokens — directly into the code, even “temporarily.” Once a secret is committed to Git history, it can remain recoverable from that history indefinitely, even after later being deleted from the current files, unless the history itself is rewritten and every old copy is invalidated.

Security-conscious teams treat certain kinds of changes — authentication logic, payment handling, access-control rules, anything touching user data — as requiring mandatory review from someone with security expertise, not just any available teammate. Some organizations enforce this automatically: a repository can be configured so specific file paths always require a specific reviewer or team, regardless of who wrote the change.

Review also acts as a check against a specific, well-documented risk called a supply-chain attack, where a contributor (or a compromised account) tries to sneak malicious code into a project disguised as a legitimate, helpful change. Careful review of what a change actually does — not just what its description claims — is one of the few defenses against this kind of attack. Payment handling, authentication, and access-control changes deserve this level of scrutiny most of all.

Finally, most platforms let teams require that reviews come from someone other than the change’s author — a rule usually called requiring “review from a different person,” which exists specifically so a single compromised or careless account cannot approve its own risky changes.

7Best Practices & Common Mistakes

Reviewing code well — and having your code reviewed well — is a skill that improves with deliberate practice.
1

Write a Clear Description First

Before requesting review, explain in the pull request what the change does and why, so reviewers don’t have to reverse-engineer your intent from the diff alone.

2

Keep Changes Small

Split large efforts into a series of small pull requests. This alone is the single biggest improvement most teams can make to review quality.

3

Comment on the Code, Not the Coder

Phrase feedback about the change itself (“this loop could run twice on empty input”) rather than about the person, which keeps review collaborative rather than adversarial.

4

Distinguish Must-Fix From Nice-to-Have

Many teams label comments (for example, as “blocking” versus “optional”) so authors know what genuinely needs to change before merging.

5

Respond Promptly

A pull request sitting unreviewed for days blocks the author and everyone waiting on that work — fast turnaround is itself a best practice.

Common mistakes beginners make: taking review comments personally instead of as feedback on the code; approving a pull request without actually running or reading it carefully because a teammate seems trustworthy; and, as an author, responding defensively to comments instead of asking clarifying questions when feedback is unclear.

8Advantages, Disadvantages & Trade-offs

Code review is not free — it costs real time from real people — even though its benefits are well established.
AspectBenefitTrade-off / Cost
QualityCatches bugs, security issues, and design problems before releaseAdds a waiting step between “code written” and “code shipped”
Knowledge sharingSpreads understanding of the codebase across the team, reducing single points of failureRequires reviewers to spend time understanding code they didn’t write
ConsistencyKeeps code style and architecture aligned across many contributorsCan slow down contributors who disagree with team conventions
Team cultureBuilds shared ownership and trust in the codebasePoorly run reviews can create friction or discourage junior contributors
SpeedSmall, well-reviewed changes are safer to ship quickly and confidentlyOverly strict or slow review processes can bottleneck delivery

The core trade-off to internalize is this: code review trades a small, predictable delay now for a much larger, unpredictable cost avoided later — the cost of a bug, security incident, or unmaintainable code discovered after release. Teams that skip review to move faster in the short term often pay for it with slower, riskier changes down the line.

9Real-World Examples

Seeing how different kinds of projects approach code review makes the practice concrete.

Large Open-Source Projects

Major open-source projects, including large web frameworks and operating-system components, require every single change — even from the most senior maintainers — to go through a public pull request with visible review comments, because transparency and consistency matter as much as catching bugs.

Cloud Infrastructure Teams

Teams responsible for infrastructure that other services depend on often require two independent approvals plus a full suite of automated tests passing before any change can merge, because a mistake there can cascade into an outage affecting many other systems at once.

Fast-Moving Startups

Small startup teams often use a lighter version of review — a single quick approval from any available teammate — prioritizing speed, while still keeping the core safeguard: no code reaches production without at least one other person having looked at it.

Regulated Industries

In industries like banking or healthcare software, code review is often a formal, auditable requirement — every approval, comment, and decision is logged, because regulators may later need proof that changes were properly checked before release.

10Frequently Asked Questions

Q1Does Git have a built-in code review feature?
No. Git itself only provides the underlying mechanism — branches and commit history. The actual review workflow, including pull requests, comments, and approvals, is provided by hosting platforms like GitHub and GitLab, or dedicated tools like Gerrit, built on top of Git.
Q2What’s the difference between a pull request and a code review?
A pull request is the container — the formal request to merge a branch — while code review is the activity that happens inside it: reading the diff, leaving comments, requesting changes, and approving.
Q3How many reviewers should a pull request have?
There’s no universal number. Many teams require at least one approval for routine changes and two for especially risky or critical ones, but this is a team policy choice rather than a Git rule.
Q4Can code review be automated entirely?
Automated tools (linters, test suites, security scanners) can catch many mechanical issues, but they cannot yet reliably judge whether a design makes sense or whether the code solves the right problem — that judgment is why human review remains standard practice.
Q5What happens if reviewers disagree with each other?
Most teams resolve disagreements through discussion directly on the pull request, and if it isn’t resolved, escalate to a team lead or a documented team convention, rather than letting the pull request stay stuck indefinitely.
Q6Is code review only for finding bugs?
No. As covered in Chapter 4, review also checks design, readability, test coverage, and security — and it doubles as a way for team members to learn from each other’s code, even when no bug is found at all.

11Summary and Key Takeaways

What to Remember

  • Code review is a workflow, not a Git command. Git provides branches and history; platforms like GitHub build pull-request review on top of them.
  • Its core purpose is a second set of eyes — catching bugs, security issues, and design problems the original author couldn’t see themselves.
  • Pull requests are the standard container where the diff is shown, comments are left, changes are requested, and approvals happen.
  • Good reviews check multiple dimensions — correctness, design, readability, tests, security, performance, consistency, and scope.
  • Small, focused pull requests get reviewed better than large ones, because reviewers can hold the whole change in their head at once.
  • Review is a real security control — it’s a key defense against hardcoded secrets, supply-chain attacks, and a single compromised account approving its own changes.
  • The short delay review adds is a trade-off for avoiding the much larger cost of bugs and security incidents discovered after release.