Diff Viewer
Paste your git diff output or upload a diff file to visualize code changes with syntax highlighting.
Git Diff Tutorial
Learn how to save git diff output to files for various scenarios - perfect for code reviews, patches, and documentation
Saving Basic Git Diffs to Files
Working Directory vs Staging
git diff > unstaged-changes.diff
Save unstaged changes to a file for review or sharing
Staging vs Last Commit
git diff --cached > staged-changes.diff
Save staged changes to file for commit review
Working Directory vs Commit
git diff HEAD > all-changes.diff
Save all changes since last commit to file
Specific File Changes
git diff path/to/file.js > file-changes.diff
Save changes for a specific file to a diff file
Saving Commit vs Commit Comparisons
Between Two Commits
git diff abc123..def456 > commit-comparison.diff
Save changes between two specific commits to file
Commit vs HEAD
git diff abc123 > commit-vs-head.diff
Save comparison of commit with current HEAD to file
Last N Commits
git diff HEAD~3..HEAD > last-3-commits.diff
Save changes from last 3 commits to file
Specific File Between Commits
git diff abc123..def456 -- file.js > file-history.diff
Save specific file changes between commits to file
Saving Branch Comparisons to Files
Branch vs Branch
git diff main..feature-branch > branch-diff.patch
Save differences between two branches as patch file
Current Branch vs Remote
git diff origin/main > remote-diff.diff
Save current branch vs remote branch differences
Three-way Merge Base
git diff main...feature-branch > merge-base.diff
Save changes from common ancestor to feature branch
Branch Files Summary
git diff main..feature --name-only > changed-files.txt
Save list of changed files between branches
Advanced Diff Options for File Saving
Ignore Whitespace
git diff -w > no-whitespace.diff
Save diff ignoring whitespace changes to file
Word-level Diff
git diff --word-diff > word-diff.diff
Save word-level differences to file
Extended Context
git diff -U10 > extended-context.diff
Save diff with 10 lines of context to file
Statistics Summary
git diff --stat > diff-stats.txt
Save file change statistics to text file
Comprehensive Guide to Saving Git Diffs
📁 Basic File Output Methods
Standard Output Redirection
git diff > changes.diff
git diff --cached > staged.patch
Append to Existing File
git diff >> all-changes.diff
git diff HEAD~1 >> history.patch
🗂️ Organized Diff File Structure
By Date and Time
git diff > "diff-$(date +%Y%m%d-%H%M%S).diff"
Creates: diff-20241230-143022.diff
By Branch and Feature
git diff main..feature > feature-branch-changes.patch
Descriptive naming for review
📋 Different Output Formats for Various Use Cases
Patch Files (.patch)
git diff > feature.patch
For applying with git apply
Text Files (.txt)
git diff --stat > summary.txt
For documentation/reports
Diff Files (.diff)
git diff HEAD~1 > review.diff
Standard diff format
⚡ Advanced Saving Scenarios
Save Multiple Comparisons
Conditional Saving (only if changes exist)
git diff --quiet || git diff > changes.diff
Save with Metadata
📋 Copy to Clipboard (Cross-Platform)
macOS
git diff | pbcopy
Linux
git diff | xclip -selection clipboard
Windows (PowerShell)
git diff | Set-Clipboard
💡 Pro Tip: After saving your diff to a file, you can upload it directly to DiffLens using the file upload area above, or copy the file content and paste it into the text area. DiffLens will automatically parse and visualize your changes with syntax highlighting and multiple view options.
🚀 Quick Start: Save Diffs to Files
git diff > changes.diff
git diff main..feature > branch.patch
git diff HEAD~2..HEAD > recent.diff
Click to upload or drag and drop
.txt, .diff, .patch files supported
Diff Results
No diff to display
Paste your git diff content or upload a diff file to get started.