37

The pager less doesn't clear the screen as it should do when i use git.

I use less all the time and it usually doesn't leave output in the terminal after quit but when less gets executed via git it leaves the output in the terminal. I'm 100% sure git uses less on my system.

What is wrong with git and how do i fix it? pager = less in ~/.gitconfig doesn't help. $PAGER is also set to less.

Kalle Richter
  • 2,472
  • 6
  • 44
  • 64
ggustafsson
  • 2,024

2 Answers2

41

The solution is to set the variable LESS. Git defaults to less FRSX.

export LESS=R

Alternatively, you can modify the variable LESS when pager is called:

git config --global core.pager 'less -+$LESS -R'

See the core.pager section in man git-config

CharlesB
  • 573
ggustafsson
  • 2,024
13

To clear the screen, but leave other behaviors untouched, you can do

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

This disables the -X option for less.

Dan
  • 231
  • 2
  • 5