Search code examples
gitgit-diff

Git diff by character other than newline


In one project I am currently working on, there is a minified JS file which, for a variety of reasons, comes from a separate project. Because it is minified, however, it does not include newlines, which means that Git diff is rendered completely useless.

Is there a way to tell git diff to compare based on a different character (such as ;) instead of newline?


Solution

  • I'm not sure if this is exactly what you're after, but I'll give it a try since no one else has answered. You might try something like:

    git diff --color-words=.
    

    Then if desired you can apply a word wrap effect by typing -S (and press [ENTER]).

    git diff's --word-diff-regex may also be of interest to you.