I\'m running git-diff on a file, but the change is at the end of a long line.
If I use cursor keys to move right, it loses colour-coding—and worse the lines do
Eight years later I find a superior answer, from https://superuser.com/questions/777617/line-wrapping-less-in-os-x-specifically-for-use-with-git-diff:
git config core.pager `fold -w 80 | less`
Now you pipe the git diff through fold, first, then to less: wrapped, less page-height is correct, keep syntax highlighting.
To use less as the pager and make line wrapping permanent you can simply enable the fold-long-lines option:
git config --global core.pager 'less -+S'
This way you do not have to type it while using less.
Cheers
Just googled up this one. GIT_PAGER='less -r'
works for me
The display of the output of git diff
is handled by whatever pager you are using.
Commonly, under Linux, less
would be used.
You can tell git to use a different pager by setting the GIT_PAGER
environment variable. If you don't mind about paging (for example, your terminal allows you to scroll back) you might try explicitly setting GIT_PAGER
to empty to stop it using a pager. Under Linux:
$ GIT_PAGER='' git diff
Without a pager, the lines will wrap.
If your terminal doesn't support coloured output, you can also turn this off using either the --no-color
argument, or putting an entry in the color section of your git config file.
$ GIT_PAGER='' git diff --no-color
Since Git 1.5.3 (Sep 2007)
a --no-pager
option has been available.
git --no-pager diff
How do I prevent git diff from using a pager?
Example
Starting with v2.1, wrap is the default
Git v2.1 Release Notes
Not a perfect solution, but gitk
and git-gui
can both show this information,
and have scrollbars.