delta Better git diffs

Version 0.20.1 · source

Start here

git diff
Diff, now highlighted
git log -p
History with patches
git show <commit>
One commit, highlighted
delta <a> <b>
Compare two files
n / N
Next / previous file in pager
delta --show-themes
Preview themes
delta --show-config
See active settings
git -c delta.side-by-side=true diff
Side-by-side once

Concepts

  1. git diff / log / show unified diff
  2. delta syntax + word diff
  3. Styled output numbers, side-by-side
  4. less scroll, n and N

Setup

git config --global core.pager delta
Send git output through delta
git config --global interactive.diffFilter "delta --color-only"
Colour git add -p
git config --global delta.navigate true
Enable n / N jumping
git config --global delta.dark true
Force dark colours (or light)
git config --global merge.conflictStyle zdiff3
Show merge base in conflicts
git config --global delta.line-numbers true
Show old and new line numbers
git config --global delta.side-by-side true
Always side-by-side
git config --global diff.colorMoved default
Detect moved code blocks
delta --version
Print installed version
delta --show-config
Show every active option
delta --no-gitconfig
Ignore gitconfig settings
delta --config <file>
Read settings from another file

Viewing diffs

git diff
Unstaged changes
git diff --staged
Staged changes
git log -p
Commits with patches
git show <commit>
One commit
delta <a> <b>
Compare two files, no repo needed
diff -u <a> <b> | delta
Highlight any unified diff
delta <(sort <a>) <(sort <b>)
Compare processed input
-s / --side-by-side
Two panels
-n / --line-numbers
Number columns
--navigate
Enable n / N
--keep-plus-minus-markers
Keep + and - prefixes
--relative-paths
Paths relative to cwd
--tabs <n>
Spaces per tab (default 8)
--max-line-length <n>
Truncate long lines (default 3000)
--width <n>
Width of decorations; variable fits text
--paging auto|always|never
When to start the pager
--pager <cmd>
Use another pager
n / N
Next / previous file (pager)
Also stops at commit boundaries in git log -p. Needs navigate on.

Side-by-side

--wrap-max-lines <n>
Cap wrapped lines per row
--wrap-right-percent <n>
Share of width for right side wraps
--wrap-left-symbol <s>
Marker for wrapped left text
--wrap-right-symbol <s>
Marker for wrapped right text
--inline-hint-style <style>
Style the wrap markers
DELTA_FEATURES=+side-by-side
Toggle on for this shell
DELTA_FEATURES=+
Switch the toggle off again
git -c delta.features=side-by-side diff
Side-by-side for one run
line-numbers-left-format = ""
Drop left number column
line-numbers-right-format = "│ "
Keep a divider only

Colours and themes

delta --show-themes
Preview delta themes on a diff
delta --list-syntax-themes
List syntax themes
delta --show-syntax-themes
Preview syntax themes
--syntax-theme <name>
Pick syntax colours (none = off)
Defaults to BAT_THEME if that is set.
--dark / --light
Defaults for terminal background
features = <theme>
Activate a named theme
--minus-style <style>
Style of removed lines
--plus-style <style>
Style of added lines
--file-style <style>
Style of file header
--hunk-header-style <style>
Style of hunk header
minus-style = red bold ul "#ffeeee"
Style: colour, attributes, background
map-styles = bold purple => syntax magenta
Restyle git's moved-line colours
features = my-theme zebra-dark
Moved lines with faint background
--true-color auto|always|never
24-bit colour output
--default-language <lang>
Fallback highlight language
delta --list-languages
Supported languages
delta --show-colors
Preview named colours
--diff-so-fancy
Emulate diff-so-fancy look
--diff-highlight
Emulate diff-highlight look

Beyond diffs

rg --json -C 2 <pattern> | delta
Highlight ripgrep results
git grep -p <pattern>
Grep with function context
--grep-output-type ripgrep|classic
Choose grep layout
[pager] blame = delta
Use delta for git blame
--blame-format <fmt>
Layout of blame lines
--blame-palette <colours>
Colours for blame blocks
--hyperlinks
Clickable hashes and paths
hyperlinks-file-link-format = "vscode://file/{path}:{line}"
Open editor at the line
hyperlinks-commit-link-format = <url>
Custom commit link URL
--merge-conflict-begin-symbol <s>
Conflict start marker
--color-only
Colour lines, keep structure
--raw
Pass input through unchanged

Recipes

Starter gitconfig
[core]    pager = delta[interactive]    diffFilter = delta --color-only[delta]    navigate = true    line-numbers = true[merge]    conflictStyle = zdiff3
Toggle side-by-side from the shell
export DELTA_FEATURES=+side-by-sidegit diff# back to normalexport DELTA_FEATURES=+
Named feature and alias
[delta "decorations"]    file-style = bold yellow ul[delta]    features = decorations[alias]    diff-sbs = -c delta.side-by-side=true diff
Compare without a repo
delta old.conf new.confdiff -u a.txt b.txt | deltarg --json -C 2 TODO | delta