问题
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'
回答1:
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.)
回答2:
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.
来源:https://stackoverflow.com/questions/54451190/displaying-git-diff-and-git-log-output-on-a-separate-terminal-screen