# Diff

> A list of the lines that changed from one version of a file to the next.

**Field:** Software Development  
**Category:** Version Control  
**Also known as:** git diff, Difference

## Think of it like

Think of it like a find the change game. The computer marks each change for you.

## Definition

A diff shows the exact lines that changed between two versions of a file. Lines that were removed start with a minus sign, and lines that were added start with a plus. You can compare your working files with the last commit, or any two commits. The git diff command prints one. Code reviews are mostly people reading diffs.

## Example

Emma runs git diff before she commits. She spots a test line she forgot to remove and deletes it first.

## Example code

```console
$ git diff
--- a/index.html
+++ b/index.html
@@ -1 +1 @@
-Hello
+Hello, world
```

The minus line was removed, and the plus line took its place.

## Why it matters

A diff shows what really changed, not what you think changed. It catches slips before they are saved.

## Common mistake

Committing without reading the diff. Stray test lines and secrets slip in that way.

## Three principles

- **Minus and plus.** Removed lines and added lines.
- **Any two versions.** Compare files, commits or branches.
- **Read before commit.** Catch stray changes early.

## Related terms

- [Commit](https://learn.benibix.com/term/development/commit)
- [Working Directory](https://learn.benibix.com/term/development/working-directory)
- [Code Review](https://learn.benibix.com/term/development/code-review)
- [Merge Conflict](https://learn.benibix.com/term/development/merge-conflict)
- [Git Status](https://learn.benibix.com/term/development/git-status)

## Taught in

- [Git Log and Git Diff](https://learn.benibix.com/learn/development-version-control/git-log-and-git-diff): Git and GitHub, 3/13

---

Source: https://learn.benibix.com/term/development/diff
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
