Displaying git diff and git log output on a separate terminal screen

…衆ロ難τιáo~ 提交于 2019-12-11 03:09:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!