22

I'm using Ubuntu 16.04 default terminal (it's GNOME I believe?)

The problem I'm facing is that when I use git diff command to inspect my local changes I can scroll up/down using the mouse wheel, but no new lines are showing up when I get to the bottom (so I can see only one page of changes). In order to go to the next lines I can use space or up/down arrows of the keyboard, but can I somehow make this with the mouse wheel?

BTW If I use the less command it works as expected -> scrolling down goes to new lines.

3 Answers 3

32

Thanks to @edwinksl's answer I managed to find a solution to the problem.

So by default git uses LESS as a pager and I believe the default arguments are FRSX.

On git 1.8+ you can remove options with less -+<option>, in my case I need to remove the X option so:

git config --global --replace-all core.pager 'less -+X'

but as @pcworld mention this can cause problems with diffs that fit on a single page, thus:

git config --global --replace-all core.pager 'less -+FX'

fixed the scrolling issue for me.

1
6

On Windows Terminal the answer didn't help me. Instead, I had to do the following:

git config --global --replace-all core.pager 'less --mouse'
3
  • @FelixDombek it worked for me on WSL 🤷‍♂️
    – Deividas
    Oct 2, 2020 at 11:21
  • 2
    Works on Linux too. The minimum version to support --mouse is 549 Oct 2, 2020 at 12:16
  • If anyone is here using github.com/so-fancy/diff-so-fancy, then include --mouse after the less --tabs=4 -RFX. Given in readme file.
    – ssi-anik
    Feb 25, 2021 at 15:20
5

From https://stackoverflow.com/a/2183920/486919, one way to do this and preserve the diff highlighting is to use git diff without a pager:

git --no-pager diff
2
  • Thank you for this answer, this help me find the exact solution I was looking for -> enabling the mouse wheel scrolling. While removing the pager is a good work-around I prefer to start reading diffs from the beginning.
    – Todor
    Jul 28, 2016 at 12:04
  • @Todor That is fair; I agree --no-pager is best for short diffs but not for long ones.
    – edwinksl
    Jul 28, 2016 at 12:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .