Using Git diff to detect code movement + How to use diff options

As of Git 2.15, git diff now supports detection of moved lines with the --color-moved option. It even detects moves between files.

It works, obviously, for colorized terminal output. As far as I can tell, there is no option to indicate moves in plain text patch format, but that makes sense.

For default behavior, try

git diff --color-moved

The command also takes options, which currently are no, default, plain, zebra and dimmed_zebra (Use git help diff to get the latest options and their descriptions). For example:

git diff --color-moved=zebra

Leave a Comment

tech