If you like to use git from the command-line and enjoy syntax highlighting, you might be interested in delta, which adds this functionality and more to git.

Tutorial

This tutorial walks through installing and configuring delta, version 0.4.4 at the time of writing, on an amd64 system running Ubuntu 20.04. It assumes you are familiar with common command-line utilities on Ubuntu, including git.

  1. Download the deb file for the latest version of delta specific to your computer’s CPU architecture.

    Releases can be found here.

    ➜ wget -q -nv -O - https://api.github.com/repos/dandavison/delta/releases/latest \
      | awk -F': ' '/browser_download_url/ && /_amd64\.deb/ && !/musl/ {gsub(/"/, "", $(NF)); system("wget -qi -L " $(NF))}'

    This one-liner downloads the amd64 deb installer for the latest release.

  2. Install the delta deb package.

    sudo apt -y install ./git-delta_*_amd64.deb
  3. Clean up the remaining deb package since it is no longer needed.

    rm git-delta_*_amd64.deb
  4. Use delta as the pager for git.

    ➜ git config --global core.pager delta
  5. Stylize diff output with delta.

    ➜ git config --global interactive.diffFilter "delta --color-only"
  6. Style moved blocks of code appropriately.

    ➜ git config --global diff.colorMoved default
  7. Customize your color scheme.

    This command sets the color scheme to Solarized Dark.

    ➜ git config --global delta.syntax-theme "Solarized (dark)"
  8. View diffs side-by-side so that they are easier to compare.

    ➜ git config --global delta.side-by-side true
  9. Show line numbers for reference.

    ➜ git config --global delta.line-numbers true
  10. Turn on extra decorations to emphasize important details, such as the file and commit information.

    ➜ git config --global delta.decorations true

Conclusion

Hopefully this improves your experience analyzing git output and diffs from the command-line.