bashintermediate
Advanced Git Diff Techniques
Compare changes between branches, commits, and working tree with filtering and formatting options.
bashPress ⌘/Ctrl + Shift + C to copy
# Working directory vs staged
git diff
# Staged vs last commit
git diff --staged
# Between two branches
git diff main..feature-branch
# Between two commits
git diff abc1234 def5678
# Only show file names
git diff --name-only main..feature-branch
# Show stat summary
git diff --stat main..feature-branch
# Filter by file type
git diff main..feature-branch -- '*.ts' '*.tsx'
# Ignore whitespace
git diff -w main..feature-branch
# Word-level diff (not line-level)
git diff --word-diff
# Show only added/deleted/modified files
git diff --diff-filter=A main..feature-branch # Added only
git diff --diff-filter=D main..feature-branch # Deleted only
git diff --diff-filter=M main..feature-branch # Modified only
# Compare specific file between branches
git diff main..feature-branch -- src/lib/registry.ts
# Create a diff patch
git diff main..feature-branch > changes.patch
# Color-moved lines detection
git diff --color-moved=dimmed-zebra
# Three-dot diff (changes since branch point)
git diff main...feature-branchUse Cases
- Reviewing changes before code review
- Comparing branches for release preparation
- Filtering diffs by file type or change kind
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
bashbeginner
Git Diff — Word, Stat, and Patch Options
Advanced diff techniques: word-level diff, stat summary, diff between branches, and patch creation.
Best for: Reviewing changes before committing
#git#diff
bashintermediate
Git Hooks Pre Commit
Git workflow: git-hooks-pre-commit
Best for: version control
#git#version-control
bashadvanced
Git Hooks Post Commit
Git workflow: git-hooks-post-commit
Best for: version control
#git#version-control
bashadvanced
Git Lfs Large Files
Git workflow: git-lfs-large-files
Best for: version control
#git#version-control