Upgrade Git Diff with Delta: Side-by-Side View and Beautiful Highlighting

Git tutorial - IT technology blog
Git tutorial - IT technology blog

When Default Git Diff is a Nightmare

It’s 2 AM, and the production server is having an issue. You need to urgently check changes in a configuration file using the git diff command. Instead of a clear interface, your Terminal displays a “forest” of plain white text mixed with a few dull red and green lines. In your sleep-deprived state, telling a comma from a semicolon becomes harder than ever.

I once spent nearly 30 minutes just finding a typo in an nginx.conf file because the default diff UI was so hard to read, even after trying to search through old code for the culprit. After that, I decided I had to find a replacement. That’s when I discovered Delta.

Essentially, Delta (or git-delta) is a tool that modernizes how we read code changes. It brings the professional review experience of GitHub or VS Code directly into your Terminal, much like Lazygit provides a visual interface for repository management.

Quick 5-Minute Installation

Instead of reading long manuals, let’s install it and feel the difference immediately.

1. Installing Delta

For macOS users, Homebrew is the fastest option:

brew install git-delta

If you’re on Ubuntu or Debian, you can download the .deb file from GitHub releases. For Rust enthusiasts, use cargo:

cargo install git-delta

2. Configuring .gitconfig

To make Delta work, you need to declare it in your ~/.gitconfig file. Paste the optimized configuration below:

[core]
    pager = delta

[interactive]
    diffFilter = delta --color-only

[delta]
    navigate = true    # Use n and N to jump between files
    light = false      # Set to true if you use a light terminal theme
    side-by-side = true # Two-column view mode
    line-numbers = true # Show line numbers

[merge]
    conflictstyle = diff3

[diff]
    colorMoved = default

After saving, try typing git diff. You’ll see a completely new interface.

Why Delta Deserves a Place in Your Toolkit

Many people hesitate to install third-party tools, but Delta solves specific pain points.

Smart Syntax Highlighting

Default Git only colors the entire line. In contrast, Delta uses the engine from the bat library to understand the syntax of over 100 languages. If you change a CSS property or a small piece of logic in Java, Delta highlights that exact keyword. Your eyes catch the change in 0.5 seconds instead of scanning character by character.

Side-by-side Mode

This is the most valuable feature on large monitors (24 inches and up). Instead of the old line sitting above the new one, Delta splits the screen for comparison. This layout makes identifying old-vs-new logic intuitive, similar to reviewing a Pull Request on GitHub or using the GitHub CLI to manage issues in the terminal.

Upgrading Git Log and Git Blame

Delta isn’t limited to the diff command. When core.pager is configured, every command that displays content benefits, including Git Blame and log outputs:

  • git log -p: Turns commit history into a list of beautiful diffs.
  • git blame: Distinguishes commit timeframes with different color bands, helping you instantly see who edited code 2 hours or 2 months ago.

Customizing Your Personal Style

Once you’re used to it, you can make Delta your own with color themes.

Using Built-in Themes

Run the command delta --list-syntax-themes to see the list. I often use the Dracula or Monokai Extended themes to reduce eye strain during night shifts. Add this line to .gitconfig to apply:

[delta]
    syntax-theme = Dracula

Notes for Small Screens

The side-by-side mode might feel a bit cramped on a 13-inch laptop. If it’s hard to read, you can limit the width or temporarily disable it with the --no-pager flag when you need to copy code quickly:

git --no-pager diff

A Real-world Lesson: Don’t Rely Solely on Colors

While the tool is powerful, colors can sometimes make us complacent. I once spent too much time looking at Delta’s lush green blocks and forgot to check the surrounding context lines. As a result, I merged a logically correct snippet but placed it in the wrong function. Always use Delta to assist your reading, but don’t forget to verify the overall file structure before hitting Enter.

Conclusion

Installing Delta is a small change that yields big results for daily productivity, especially when combined with Conventional Commits to keep your history clean. It makes code reviews less stressful and more professional. If you spend more than 2 hours a day working with Git, Delta is definitely a worthwhile investment.

Share: