Skip to content
BENIBIX Learn

Diff

Development🔀 Version ControlGit Basics

Also known as git diff, Difference

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

Think of it like

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

Example

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

Why it matters

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

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 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.

Common mistake

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

Key takeaways

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

Learn it properly