Skip to content

Delta Cheatsheet

Delta Cheatsheet

Installation

PlatformCommand
Ubuntu/Debianwget 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 Linuxsudo pacman -S git-delta
Fedora/RHELsudo dnf install git-delta
Alpine Linuxapk 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 Installationdelta --version

Basic Commands

CommandDescription
git config --global core.pager deltaSet delta as default Git pager
git diffView unstaged changes with delta
git diff --cachedView staged changes with delta
git diff path/to/file.pyView changes in specific file
git diff mainCompare current branch with main
git diff branch1..branch2Compare two branches
git show HEADShow last commit with diff
git show abc123Show specific commit with diff
git log -pView commit history with diffs
git diff commit1 commit2Compare two specific commits
diff file1.txt file2.txt | deltaPipe standard diff output to delta
delta file1.txt file2.txtCompare files directly with delta
delta --show-syntax-themesDisplay all available syntax themes
delta --list-languagesList all supported programming languages
delta --show-configDisplay current delta configuration
git blame file.pyView git blame with delta formatting
git grep "function" | deltaEnhanced grep output with delta
git diff --statShow diff statistics with delta
git diff -w | deltaView diff ignoring whitespace changes
delta changes.diffView a saved diff file with delta

Advanced Usage

CommandDescription
git diff | delta --side-by-sideEnable side-by-side diff view
git diff | delta --side-by-side --width 200Side-by-side with custom width
git diff | delta --line-numbersEnable line numbers in diff output
git diff | delta --syntax-theme MonokaiUse specific syntax theme temporarily
git diff | delta --language pythonForce specific language syntax highlighting
git config --global delta.side-by-side trueEnable side-by-side mode globally
git config --global delta.line-numbers trueEnable line numbers globally
git config --global delta.navigate trueEnable navigation mode for jumping between files
git config --global delta.hyperlinks trueEnable clickable file path hyperlinks
git config --global diff.colorMoved defaultHighlight moved code blocks
git config --global pager.blame deltaUse delta for git blame output
git config --global pager.grep deltaUse 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.pyView blame for specific line range with delta
git diff --word-diffShow 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 | deltaIgnore whitespace at end of line
git config --global delta.max-line-length 512Set maximum line length for display
git config --global delta.tabs 4Set 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
  • Monokai Extended
  • Nord
  • Dracula
  • gruvbox-dark
  • gruvbox-light
  • Solarized (dark)
  • Solarized (light)
  • GitHub
  • OneHalfDark
  • OneHalfLight

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 delta once to use delta for all repositories, ensuring consistent diff viewing experience.

  • Enable navigation mode: Use git config --global delta.navigate true to quickly jump between files in large diffs using n (next) and N (previous) keys.

  • Choose appropriate themes: Select syntax themes that match your terminal background (dark/light) and provide good contrast. Test with delta --show-syntax-themes to preview all options.

  • Use side-by-side for reviews: Enable side-by-side = true for 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 = default to 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 features option.

  • Optimize for your workflow: Adjust width, tabs, and wrap-max-lines settings based on your typical terminal size and coding standards to prevent awkward line breaks.

  • Use with interactive commands: Configure interactive.diffFilter = delta --color-only to get delta’s highlighting in git add -p and 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

IssueSolution
Delta not being used for diffsVerify configuration with git config --global core.pager - should return delta. If not, run git config --global core.pager delta
Colors not displaying correctlyCheck terminal supports 24-bit color. Set COLORTERM=truecolor environment variable. Try different syntax themes with delta --show-syntax-themes
Side-by-side view is garbledTerminal 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 showingEnable explicitly: git config --global delta.line-numbers true. Check that feature isn’t disabled in a custom feature set
Syntax highlighting not workingVerify file extension is recognized with delta --list-languages. Force language with --language option or check syntax-theme setting
Delta not working in git add -pSet interactive diff filter: git config --global interactive.diffFilter "delta --color-only". The --color-only flag is essential for interactive mode
Pager quits immediatelyAdjust 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 diffsDisable side-by-side mode, reduce max-line-length, or use --syntax-theme none to disable syntax highlighting for faster rendering
Hyperlinks not clickableEnsure terminal supports hyperlinks (iTerm2, kitty, Alacritty). Enable with git config --global delta.hyperlinks true
Configuration not taking effectCheck for conflicting configs: `git config —list
Unicode characters displaying incorrectlyEnsure 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 highlightedEnable in Git: git config --global diff.colorMoved default. Then set delta style: git config --global delta.color-moved-style syntax