DEV Community

Cover image for Delta: A new git diff tool to rock your productivity
Axel Navarro for Cloud(x);

Posted on • Edited on

Delta: A new git diff tool to rock your productivity

The delta tool (a.k.a. git-delta, a.k.a. delta-diff) is a diff viewer written in Rust πŸ’ͺ. Initially made to have a better Developer Experience using the git diff command, but has evolved enough transcending a simple diff for git.

Installation

In windows, you can just download the delta.exe program from the official repository, or use a tool like: choco install delta or scoop install delta.

In MacOS, you could use brew install git-delta.

Linux has a lot of alternatives, download the Debian package from the releases page, or run dnf install git-delta in Fedora, or pacman -S git-delta in Archlinux.

Or, find your destiny here: https://dandavison.github.io/delta/installation.html.

The basics

The basic usage is set delta as your pager (make sure delta is in your PATH variable)



git config --global core.pager delta
git show 0ff1a88cc


Enter fullscreen mode Exit fullscreen mode

Delta sections

You can use --light or --dark to adjust the delta colors in your terminal:



git config --global core.pager "delta --dark"
git diff -- ClientApp/src/hook/useBrowserHardwarePermissions.ts


Enter fullscreen mode Exit fullscreen mode

delta in dark mode

Show line numbers!

Do you want to display line numbers? easy-peasy!



git config --global core.pager "delta --line-numbers --dark"


Enter fullscreen mode Exit fullscreen mode

delta with line numbers

Delta vs GitHub

A simple comparison between the default format delta output and a GitHub diff view.

delta GitHub
delta GitHub

Side by side πŸš€

You can view a side-by-side diff view with -s or --side-by-side to see your git diff in a really new way:

Delta with side by side view

This feature rocks! And you can enable this in git using:



git config --global delta.side-by-side true


Enter fullscreen mode Exit fullscreen mode

Other usages

Comparing outside the land of git

delta is not limited to git. We can use delta to show a diff of 2 files.



delta dnscrypt-proxy.toml.pacnew dnscrypt-proxy.toml


Enter fullscreen mode Exit fullscreen mode

delta 2 files

Comparing two folders

We can compare 2 folders to see the diffences:



delta dir1 dir2


Enter fullscreen mode Exit fullscreen mode

Delta directory example

More delta

You have a lot of possible customization options you could investigate in the user manual or set the colors of your choice in your .gitconfig file. And this is only the version 0.3.0 of this young app.

Thanks to Dan Davison for this awesome tool! and if you πŸ’› it too, leave a ⭐ in https://github.com/dandavison/delta.

Top comments (6)

Collapse
 
terkwood profile image
Felix Terkhorn

I'm excited about this for two reasons:

  • I need a better dark mode solution for my reviews, like, yesterday... I know I can install some creepy browser extension and make Github dark, but I'm too paranoid to allow that! πŸ‘“
  • Love seeing CLI rust apps take over the world πŸ¦€

Thanks for posting. This is now on my shortlist of stuff to try out.

Collapse
 
keonik profile image
John Fay

Hey Felix! You can turn on dark mode in Github today.

  1. Login
  2. visit Appearance settings and change it up
Collapse
 
terkwood profile image
Felix Terkhorn

Yah, it's fantastic!

Collapse
 
drumm profile image
Sam J.

I love this tool!!
Q: I like to switch between side-by-side and normal view, is there an easy way to pass an argument to git diff iso changing the global setting? Thx!

Collapse
 
navarroaxel profile image
Axel Navarro • Edited

Good question! It's explained here: dandavison.github.io/delta/configu...

You can change delta options for an one-off Git command using: git -c

The answer is:

git -c delta.side-by-side=true diff --
Enter fullscreen mode Exit fullscreen mode
Collapse
 
codigo47 profile image
codigo47

Amazing!, I use GitAhead, but this tool makes things easier and faster for quick diffs