Zum Inhalt

_

_

_

Delta Cheatsheet

• Installation

Platform Command
Ubuntu/Debian INLINE_CODE_8
Arch Linux INLINE_CODE_9
Fedora/RHEL INLINE_CODE_10
Alpine Linux INLINE_CODE_11
macOS (Homebrew) INLINE_CODE_12
macOS (MacPorts) INLINE_CODE_13
Windows (Scoop) INLINE_CODE_14
Windows (Chocolatey) INLINE_CODE_15
Windows (Winget) INLINE_CODE_16
Any (Cargo) INLINE_CODE_17
Verify Installation INLINE_CODE_18
_
oder Grundlegende Befehle
Command Description
INLINE_CODE_19 Set delta as default Git pager
INLINE_CODE_20 View unstaged changes with delta
INLINE_CODE_21 View staged changes with delta
INLINE_CODE_22 View changes in specific file
INLINE_CODE_23 Compare current branch with main
INLINE_CODE_24 Compare two branches
INLINE_CODE_25 Show last commit with diff
INLINE_CODE_26 Show specific commit with diff
INLINE_CODE_27 View commit history with diffs
INLINE_CODE_28 Compare two specific commits
INLINE_CODE_29 Pipe standard diff output to delta
INLINE_CODE_30 Compare files directly with delta
INLINE_CODE_31 Display all available syntax themes
INLINE_CODE_32 List all supported programming languages
INLINE_CODE_33 Display current delta configuration
INLINE_CODE_34 View git blame with delta formatting
INLINE_CODE_35 Enhanced grep output with delta
INLINE_CODE_36 Show diff statistics with delta
INLINE_CODE_37 View diff ignoring whitespace changes
INLINE_CODE_38 View a saved diff file with delta

/ Fortgeschrittene Nutzung

Command Description
INLINE_CODE_39 Enable side-by-side diff view
INLINE_CODE_40 Side-by-side with custom width
INLINE_CODE_41 Enable line numbers in diff output
INLINE_CODE_42 Use specific syntax theme temporarily
INLINE_CODE_43 Force specific language syntax highlighting
INLINE_CODE_44 Enable side-by-side mode globally
INLINE_CODE_45 Enable line numbers globally
INLINE_CODE_46 Enable navigation mode for jumping between files
INLINE_CODE_47 Enable clickable file path hyperlinks
INLINE_CODE_48 Highlight moved code blocks
INLINE_CODE_49 Use delta for git blame output
INLINE_CODE_50 Use delta for git grep output
INLINE_CODE_51 Use delta in interactive Git commands
INLINE_CODE_52 View blame for specific line range with delta
INLINE_CODE_53 Show word-level differences with delta
INLINE_CODE_54 Customize pager behavior
INLINE_CODE_55 Enable multiple features at once
INLINE_CODE_56 Ignore whitespace at end of line
INLINE_CODE_57 Set maximum line length for display
INLINE_CODE_58 Set tab width for display
_
Konfiguration

Delta ist über Gits Konfigurationssystem konfiguriert. Die Konfiguration kann global (~/.gitconfig) oder per-repository (.git/config_) eingestellt werden.

Grundkonfiguration

[core]
    pager = delta

[interactive]
    diffFilter = delta --color-only

[delta]
    navigate = true
    line-numbers = true
    side-by-side = true

Vollständiges Konfigurationsbeispiel

[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

Benutzerdefinierte Feature Sets

Erstellen Sie wiederverwendbare Konfigurationsprofile:

[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

Beliebte Syntax Themes

Monokai Extended_ Nord_ Dracula_ gruvbox-dark_ gruvbox-light Solarized (dark) Solarized (light) GitHub_ OneHalfDark_ OneHalfLight_

Häufige Anwendungsfälle

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 Zweige 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: Code History untersuchen

# 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: Verschmelzung Konfliktlösung

# 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: Erstellung lesbarer 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

oder Best Practices

  • **Set delta global*: Konfigurieren Sie __INLINE_CODE_71_ einmal, um Delta für alle Repositories zu verwenden, um ein einheitliches Diff-Betrachtungserlebnis zu gewährleisten.

  • ** Navigationsmodus aktivieren*: Verwenden Sie git config --global delta.navigate true, um schnell zwischen Dateien in großen Diffs mit __INLINE_CODE_73_ (next) und N (previous) Tasten zu springen.

  • **Choose passend Themen*: Wählen Sie Syntax-Themen aus, die Ihrem Terminal-Hintergrund (dark/light) entsprechen und einen guten Kontrast bieten. Testen Sie mit delta --show-syntax-themes, um alle Optionen zu sehen.

  • **Ne Seite für Bewertungen*: Aktivieren Sie side-by-side = true für Code-Reviews und Zusammenführen von Vergleichen, deaktivieren Sie es aber für schnelle Überprüfungen an schmalen Terminals, um Probleme der Linienumwicklung zu vermeiden.

  • ** Linienzahlen strategisch konfigurieren*: Aktivieren Sie Zeilennummern für Debugging- und Code-Bewertungen (line-numbers = true), aber erwägen Sie die Deaktivierung für einfache Diffs, um visuellen Cutter zu reduzieren.

  • Veränderte Codeerkennung: Setzen Sie diff.colorMoved = default, um den Code hervorzuheben, der eher bewegt wurde als geändert, wodurch Refactoring-Rezensionen deutlicher werden.

  • **Benutzerdefinierte Feature-Sets erstellen*: Definieren Sie mehrere Delta-Konfigurationen für verschiedene Workflows (z.B. "Review", "quick-Check", "Präsentation") und wechseln Sie zwischen ihnen nach Bedarf mit der features Option.

  • ** Optimieren Sie Ihren Workflow*: Passen Sie width_, tabs und wrap-max-lines auf Basis Ihrer typischen Terminalgröße und Kodierung Standards an, um unangenehme Linienbrüche zu verhindern.

  • ** Verwenden Sie interaktive Befehle*: Konfigurieren interactive.diffFilter = delta --color-only, um deltas Highlighting in __INLINE_CODE_84_ und anderen interaktiven Git-Befehlen zu erhalten.

  • **Kombination mit Git aliases*: Erstellung Git Aliases, die delta-spezifische Optionen für gemeinsame Aufgaben umfassen, wie git config --global alias.review 'diff --color-moved' für standardisierte Überprüfung Workflows.

Fehlerbehebung

Issue Solution
Delta not being used for diffs Verify configuration with INLINE_CODE_86 - should return INLINE_CODE_87. If not, run INLINE_CODE_88
Colors not displaying correctly Check terminal supports 24-bit color. Set INLINE_CODE_89 environment variable. Try different syntax themes with INLINE_CODE_90
Side-by-side view is garbled Terminal width may be too narrow. Disable with INLINE_CODE_91 or increase terminal width. Adjust with INLINE_CODE_92 option
Line numbers not showing Enable explicitly: INLINE_CODE_93. Check that feature isn't disabled in a custom feature set
Syntax highlighting not working Verify file extension is recognized with INLINE_CODE_94. Force language with INLINE_CODE_95 option or check INLINE_CODE_96 setting
Delta not working in git add -p Set interactive diff filter: INLINE_CODE_97. The INLINE_CODE_98 flag is essential for interactive mode
Pager quits immediately Adjust pager settings: INLINE_CODE_99. The INLINE_CODE_100 flag causes less to quit if output fits on one screen
Performance issues with large diffs Disable side-by-side mode, reduce INLINE_CODE_101, or use INLINE_CODE_102 to disable syntax highlighting for faster rendering
Hyperlinks not clickable Ensure terminal supports hyperlinks (iTerm2, kitty, Alacritty). Enable with INLINE_CODE_103
Configuration not taking effect Check for conflicting configs: INLINE_CODE_104. Repository-level configs override global. Use INLINE_CODE_105 to see active settings
Unicode characters displaying incorrectly Ensure terminal uses UTF-8 encoding. Set INLINE_CODE_106 or similar locale. Check font supports Unicode characters used in decorations
**Geänderter Code nicht hervorgehoben* Aktivieren in Git: git config --global diff.colorMoved default. Dann set delta style: git config --global delta.color-moved-style syntax