2-node-supercomputer.net 2018-11-21

Word-wise git diff, number-wise git diff

Ah, one of those gems that make your life easier. Git allows you to do a word-by-word diff, and you don’t need to use a special tool for it:

$ git diff --word-diff

This will show the old word in red, the new replacement in green, if color is enabled.

For number comparison it is better to reduce the amount difference even further:

$ git diff --word-diff-regex=.

This will show the difference character-by-character, which is pretty much what you want when comparing numbers, and you expect only changes of order machine precision.

Of course, it doesn’t parse numbers, e.g. 168898766763e-21 is not automatically matched with 1.68898766763e-5 (or whatever it is). Nevertheless, still an improvement over the full number.