4

After setting up new development environment I encountered a strange git behavior that I don't recall seeing in the past.

I am used to git diff and git log creating a new screen in the terminal and displaying their output inside (what less does by default, and I'm using it as my pager).

I can then quit and go back to my previous terminal state, with the command output gone. Now, however, output is printed right into the same screen as if it was cat (but with a pager). Any ideas how to fix this? Couldn't find any info online.

UPDATE: Was able to fix this with @torek's help by setting core.pager to 'less -+F -+X'

dols3m
  • 1,676
  • 2
  • 16
  • 25

2 Answers2

2

You probably have less set to use -X now, when you previously had less set not to use -X.

See my answer to How to display output of `git branch` on-screen in same CLI terminal?. Note that you can choose which pager to use, and/or whether to use a pager, too. (Well, you noted this in your question.)

torek
  • 448,244
  • 59
  • 642
  • 775
  • Hmm, this seems to be the case indeed. But how do I turn that option off? My `core.pager` is set to just `less -F`, while `$LESS` and `$GIT_PAGER` environment variables are not set. – dols3m Jan 30 '19 at 23:57
  • And by the way, alternate screen is enabled in my terminal, less by itself behaves like expected. – dols3m Jan 30 '19 at 23:58
  • 2
    If `$LESS` *isn't* set, Git sets it to `-FRX`, which enables those three options. You coud, for instance, set `core.pager` to `less -F -+X`, or (my preference) set `core.pager` to `less` and set `LESS` to `-FR`. The latter will affect other invocations of less, setting both `-F` and `-R`. (Git's sneaky "set $LESS if not set" thing is, well, sneaky.) – torek Jan 31 '19 at 00:11
0

Check the PAGER environment variable. This controls which tools is used by various programs to page through output.

export PAGER=less
git diff

If this works for you, you can then set this as a permanent environment variable in various ways depending on your operating system.

hipyhop
  • 179
  • 4
  • 12