switch·Esc back

Diff

You might say

Show me exactly what changed this time—what lines were added and what lines were removed.

See exactly what changed between two statesA diff shows added, removed, and modified lines between the working tree, staged changes, commits, or branches. Read it before committing and reviewing so accidental edits, secrets, and unrelated changes are caught early.
Know first
Before changesButton text Click me
After changesButton text Start now
git diff

Diff is a list of changes: red minus signs indicate deleted content, and green plus signs indicate new content. Read it over before submitting to make sure there are no accidentally deleted, debugged content or keys.

When to use it

  • Review work before a commit
  • Compare two branches or commits
  • Understand a pull request
  • Find an accidental or missing change

When NOT to use it

  • Review only the filenames and skip the actual lines
  • Assume a small diff has a small product impact
  • Include formatting changes that hide the real edit
  • Copy secrets into a diff shared outside the team
Anatomy
📄 index.html @@ -12,5 +12,5 @@ - +
Which file does this change belong to? One file and one section.
@@ -12,5 +12,5 @@: Change near line 12
Red with - sign: lines that existed in the old version and deleted in the new version
Green with a + sign: extra lines in the new version
Variants
git diff
git diff
Check what has been changed in the workspace relative to the staging area
git diff --staged
git diff --staged
Review after add and before commit
git diff commits
git diff HEAD~1 HEAD
Review specific changes from the most recent commit
git diff main..feat
git diff main..feat/dark-mode
Before merging, check how far ahead the branch is
Typical use cases
Pre-commit review
zsh — my-first-page
$ git diff diff --git a/index.html b/index.html @@ -12,5 +12,5 @@ - + The red band - is deleted, the green band + is added
Pull request
zsh — my-first-page
$ git diff HEAD~1 HEAD --stat index.html | 10 ++++++---- style.css | 12 ++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) $ git diff HEAD~1 HEAD Check the line-by-line details again to confirm the content of this round of AI modifications
Bug investigation
ConversationCommits 3Checks ✓Files changed 2
📄 index.html +18 −4
@@ -12,5 +12,5 @@
-
+
Release comparison
🤖 AI finishes a round of changes 🔍 review git diff line by line ✅ git commit record
Further reading