Git diff with long lines

I find git diff output is not easy to read when the text file contains long lines that is long enough to exceeds the screen size.

We may not forbid the using the long lines for all files.

How to handle lone lines in git diff better?

Two possible methods to make git diff with long lines easier to read:

Method 1: Git can highlight changes in lines instead of showing two lines of each version:

git diff --word-diff

It will prints changes in format like:

[-deleted word-]{+added_word+}

Method 2: Make git wrap long lines:

PAGER='' git diff --word-diff

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *