Last Updated: February 25, 2016
·
1.673K
· x3ro

Source control for documents - Git Word Diff

For all of you who check your <favorite markup language here> files into Git source control, you might want to know about word diffs:

git diff --word-diff

This will highlight the individual words changed in a line, and not the entire line, which is really useful if, for example, you write your paragraphs in a single line. This however still uses less (or whatever pager you have configured), so the lines will probably not wrap around in the terminal. Therefore I always disable the pager entirely when using word-diff:

GIT_PAGER='' git diff --word-diff

Or in short, as an alias in your .bash_profile:

alias gwd="GIT_PAGER='' git diff --word-diff"

1 Response
Add your response

Nice option, thanks for sharing. Note that you can disable the pager using the --no-pager option: $ git --no-pager diff --word-diff

over 1 year ago ·