Read more

Git diff: Deemphasizing code that was only moved around

Dominik Schöler
January 04, 2021Software engineer at makandra GmbH

In long diffs, it can become impossible to spot small changes in larger blocks of moved code. This may be either a method that was moved from the top to the bottom of a file, or a long test file that was split in many.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

Fortunately, Git offers a special highlighting mode that directs the reader's attention to relevant code parts:

git diff --color-moved=dimmed-zebra

It will dim lines that were moved around without changes, and highlight changed lines.
To easily use dimmed-zebra mode, configure an alias:

# ~/.gitconfig
[alias]
  dz = diff --color-moved=dimmed-zebra

Example taken from Stackoverflow Show archive.org snapshot :
Git dimmed-zebra

Posted by Dominik Schöler to makandra dev (2021-01-04 08:06)