Delta Cheatsheet
Delta Cheatsheet
Installation
| Platform | Command |
|---|---|
| Ubuntu/Debian | wget https://github.com/dandavison/delta/releases/download/0.16.5/git-delta_0.16.5_amd64.deb && sudo dpkg -i git-delta_0.16.5_amd64.deb |
| Arch Linux | sudo pacman -S git-delta |
| Fedora/RHEL | sudo dnf install git-delta |
| Alpine Linux | apk add git-delta |
| macOS (Homebrew) | brew install git-delta |
| macOS (MacPorts) | sudo port install git-delta |
| Windows (Scoop) | scoop install delta |
| Windows (Chocolatey) | choco install delta |
| Windows (Winget) | winget install dandavison.delta |
| Any (Cargo) | cargo install git-delta |
| Verify Installation | delta --version |
Basic Commands
| Command | Description |
|---|---|
git config --global core.pager delta | Set delta as default Git pager |
git diff | View unstaged changes with delta |
git diff --cached | View staged changes with delta |
git diff path/to/file.py | View changes in specific file |
git diff main | Compare current branch with main |
git diff branch1..branch2 | Compare two branches |
git show HEAD | Show last commit with diff |
git show abc123 | Show specific commit with diff |
git log -p | View commit history with diffs |
git diff commit1 commit2 | Compare two specific commits |
diff file1.txt file2.txt | delta | Pipe standard diff output to delta |
delta file1.txt file2.txt | Compare files directly with delta |
delta --show-syntax-themes | Display all available syntax themes |
delta --list-languages | List all supported programming languages |
delta --show-config | Display current delta configuration |
git blame file.py | View git blame with delta formatting |
git grep "function" | delta | Enhanced grep output with delta |
git diff --stat | Show diff statistics with delta |
git diff -w | delta | View diff ignoring whitespace changes |
delta changes.diff | View a saved diff file with delta |
Advanced Usage
| Command | Description |
|---|---|
git diff | delta --side-by-side | Enable side-by-side diff view |
git diff | delta --side-by-side --width 200 | Side-by-side with custom width |
git diff | delta --line-numbers | Enable line numbers in diff output |
git diff | delta --syntax-theme Monokai | Use specific syntax theme temporarily |
git diff | delta --language python | Force specific language syntax highlighting |
git config --global delta.side-by-side true | Enable side-by-side mode globally |
git config --global delta.line-numbers true | Enable line numbers globally |
git config --global delta.navigate true | Enable navigation mode for jumping between files |
git config --global delta.hyperlinks true | Enable clickable file path hyperlinks |
git config --global diff.colorMoved default | Highlight moved code blocks |
git config --global pager.blame delta | Use delta for git blame output |
git config --global pager.grep delta | Use delta for git grep output |
git config --global interactive.diffFilter "delta --color-only" | Use delta in interactive Git commands |
git blame -L 10,20 file.py | View blame for specific line range with delta |
git diff --word-diff | Show word-level differences with delta |
git config --global delta.pager "less -RFX" | Customize pager behavior |
git config --global delta.features "line-numbers decorations" | Enable multiple features at once |
git diff --ignore-space-at-eol | delta | Ignore whitespace at end of line |
git config --global delta.max-line-length 512 | Set maximum line length for display |
git config --global delta.tabs 4 | Set tab width for display |
Configuration
Delta is configured through Git’s configuration system. Configuration can be set globally (~/.gitconfig) or per-repository (.git/config).
Basic Configuration
[core]
pager = delta
[interactive]
diffFilter = delta --color-only
[delta]
navigate = true
line-numbers = true
side-by-side = true
Complete Configuration Example
[core]
pager = delta
[interactive]
diffFilter = delta --color-only
[delta]
# General settings
navigate = true
light = false
side-by-side = true
line-numbers = true
hyperlinks = true
# Syntax highlighting
syntax-theme = Monokai Extended
# Layout
width = 200
tabs = 4
wrap-max-lines = unlimited
# Line numbers
line-numbers-left-format = "{nm:>4}│"
line-numbers-right-format = "{np:>4}│"
line-numbers-minus-style = "red"
line-numbers-plus-style = "green"
line-numbers-zero-style = "white dim"
# Colors and styles
minus-style = syntax "#3f0001"
minus-non-emph-style = syntax "#3f0001"
minus-emph-style = syntax "#901011"
minus-empty-line-marker-style = normal "#3f0001"
plus-style = syntax "#002800"
plus-non-emph-style = syntax "#002800"
plus-emph-style = syntax "#007800"
plus-empty-line-marker-style = normal "#002800"
# Commit and file decoration
commit-decoration-style = bold yellow box ul
file-decoration-style = blue ul
file-style = bold yellow ul
hunk-header-decoration-style = blue box
hunk-header-style = file line-number syntax
# Whitespace
whitespace-error-style = reverse red
# Moved code detection
color-moved-style = syntax
[diff]
colorMoved = default
Custom Feature Sets
Create reusable configuration profiles:
[delta "my-dark-theme"]
syntax-theme = Dracula
line-numbers = true
side-by-side = true
navigate = true
minus-style = syntax "#450a15"
plus-style = syntax "#0a4514"
[delta "my-light-theme"]
syntax-theme = GitHub
light = true
line-numbers = true
side-by-side = false
[delta]
features = my-dark-theme
Popular Syntax Themes
Monokai ExtendedNordDraculagruvbox-darkgruvbox-lightSolarized (dark)Solarized (light)GitHubOneHalfDarkOneHalfLight
Common Use Cases
Use Case 1: Daily Code Review Workflow
# Configure delta for optimal code review
git config --global core.pager delta
git config --global delta.side-by-side true
git config --global delta.line-numbers true
git config --global delta.navigate true
# Review changes before committing
git diff
# Review staged changes
git diff --cached
# Review specific file changes
git diff path/to/modified/file.js
Use Case 2: Comparing Branches for Merge
# Compare feature branch with main
git diff main..feature-branch
# View side-by-side comparison with context
git diff main..feature-branch | delta --side-by-side --width 180
# Check for moved code blocks
git diff --color-moved main..feature-branch
# Review specific file differences between branches
git diff main..feature-branch -- src/app.py
Use Case 3: Investigating Code History
# View commit history with diffs
git log -p --follow path/to/file.py
# Compare specific commits
git diff abc123..def456
# Show changes in a specific commit
git show abc123
# View blame with delta formatting
git blame -L 50,100 src/main.rs
# Search for changes in history
git log -p -S "function_name" | delta
Use Case 4: Merge Conflict Resolution
# Enable side-by-side view for conflicts
git config --global delta.side-by-side true
git config --global delta.line-numbers true
# View conflicted files
git diff --name-only --diff-filter=U
# Examine conflicts in detail
git diff path/to/conflicted/file.py
# Compare with both parents during merge
git diff HEAD
git diff MERGE_HEAD
Use Case 5: Creating Readable Diff Reports
# Generate formatted diff for documentation
git diff main..feature > changes.diff
delta changes.diff > formatted-changes.txt
# Create side-by-side comparison
git diff --stat main..feature
git diff main..feature | delta --side-by-side --width 200
# Export with specific theme for presentations
git diff | delta --syntax-theme "Monokai Extended" --line-numbers
Best Practices
-
Set delta globally: Configure
git config --global core.pager deltaonce to use delta for all repositories, ensuring consistent diff viewing experience. -
Enable navigation mode: Use
git config --global delta.navigate trueto quickly jump between files in large diffs usingn(next) andN(previous) keys. -
Choose appropriate themes: Select syntax themes that match your terminal background (dark/light) and provide good contrast. Test with
delta --show-syntax-themesto preview all options. -
Use side-by-side for reviews: Enable
side-by-side = truefor code reviews and merge comparisons, but disable it for quick checks on narrow terminals to avoid line wrapping issues. -
Configure line numbers strategically: Enable line numbers for debugging and code reviews (
line-numbers = true), but consider disabling for simple diffs to reduce visual clutter. -
Leverage moved code detection: Set
diff.colorMoved = defaultto highlight code that has been moved rather than changed, making refactoring reviews much clearer. -
Create custom feature sets: Define multiple delta configurations for different workflows (e.g., “review”, “quick-check”, “presentation”) and switch between them as needed using the
featuresoption. -
Optimize for your workflow: Adjust
width,tabs, andwrap-max-linessettings based on your typical terminal size and coding standards to prevent awkward line breaks. -
Use with interactive commands: Configure
interactive.diffFilter = delta --color-onlyto get delta’s highlighting ingit add -pand other interactive Git commands. -
Combine with Git aliases: Create Git aliases that include delta-specific options for common tasks, like
git config --global alias.review 'diff --color-moved'for standardized review workflows.
Troubleshooting
| Issue | Solution |
|---|---|
| Delta not being used for diffs | Verify configuration with git config --global core.pager - should return delta. If not, run git config --global core.pager delta |
| Colors not displaying correctly | Check terminal supports 24-bit color. Set COLORTERM=truecolor environment variable. Try different syntax themes with delta --show-syntax-themes |
| Side-by-side view is garbled | Terminal width may be too narrow. Disable with git config --global delta.side-by-side false or increase terminal width. Adjust with --width option |
| Line numbers not showing | Enable explicitly: git config --global delta.line-numbers true. Check that feature isn’t disabled in a custom feature set |
| Syntax highlighting not working | Verify file extension is recognized with delta --list-languages. Force language with --language option or check syntax-theme setting |
| Delta not working in git add -p | Set interactive diff filter: git config --global interactive.diffFilter "delta --color-only". The --color-only flag is essential for interactive mode |
| Pager quits immediately | Adjust pager settings: git config --global delta.pager "less -RFX". The -F flag causes less to quit if output fits on one screen |
| Performance issues with large diffs | Disable side-by-side mode, reduce max-line-length, or use --syntax-theme none to disable syntax highlighting for faster rendering |
| Hyperlinks not clickable | Ensure terminal supports hyperlinks (iTerm2, kitty, Alacritty). Enable with git config --global delta.hyperlinks true |
| Configuration not taking effect | Check for conflicting configs: `git config —list |
| Unicode characters displaying incorrectly | Ensure terminal uses UTF-8 encoding. Set LC_ALL=en_US.UTF-8 or similar locale. Check font supports Unicode characters used in decorations |
| Moved code not highlighted | Enable in Git: git config --global diff.colorMoved default. Then set delta style: git config --global delta.color-moved-style syntax |