18

Before, I could just type

git log

Now, I have to type:

git log | less

to get the same effect. I haven't (intentionally) changed any parameters. I've checked my global config: "~/.gitconfig" and my project Git config ".git/config" but I can't see anything that would cause this. All of the command parameters seem to be for opting out of this.

Furthermore, none of these work either:

git config --add --global core.pager less
git log

or

GIT_PAGER=less git log

or

PAGER=less git log
halfer
  • 19,824
  • 17
  • 99
  • 186
quinn
  • 5,508
  • 10
  • 34
  • 54
  • just a guess, but aside from 'global', check also the local setting stored in the specific repository – quetzalcoatl Jan 16 '14 at 13:52
  • @quetzalcoatl I clarified my original question to address this. I checked both configs. I could be missing something, but I didn't see anything that could be causing it. – quinn Jan 16 '14 at 14:19
  • 1
    I'm having the exact opposite problem. I don't want `git log` to use `less` every time, I'd like to be able to pipe it to other things, like `grep`. How do I disable this? – Michael Dorst Mar 22 '19 at 19:26

5 Answers5

8

"did you try unplugging it and plugging it back in" I opened a new terminal and it stopped happening. I am still super curious though what in that other window's environment could be causing this, so I'll leave it open for awhile and if anyone has any ideas please let me know :)

quinn
  • 5,508
  • 10
  • 34
  • 54
  • I finally typed "exit" in the terminal, and when I did, I entered into a git log in less. I typed q, and then exit again and the terminal closed. – quinn Jan 18 '14 at 18:16
  • I'm having the same issue and it's been happening for months. Still no answer in sight. – dwj Nov 15 '17 at 17:28
  • For me, it was because I fat-fingered something while within an existing `got log` command, which caused it to return to the command prompt but somehow wasn't completely reconnected to the TTY (or something, i'm not an expert on this stuff). Still not sure exactly how to reproduce though. – quinn Dec 16 '17 at 16:37
5

There are two parameters that might affect this: the core.pager Git variable, and the $PAGER environment variable. Check what you have with

git config core.pager
echo $PAGER

One of them should be set to less

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • what is the output of `git config core.pager` and `echo $PAGER`? – CharlesB Jan 16 '14 at 13:54
  • `git config core.pager` returns "less". the syntax I used in my question is equivalent using the export command (but scoped to the current running command). But, for the sake of completeness, I did `export PAGER=less` and ran `git log` with the same issue, and `echo $PAGER` returns "less". – quinn Jan 16 '14 at 14:16
  • I don't understand what's happening to you, sorry – CharlesB Jan 16 '14 at 14:19
3

I figured out the real reason when I had the issue on MSYS. It just needed the full path. e.g.

git config --add --global core.pager /usr/bin/less

(I suppose on Linux it would be similar.)

It's pretty obvious the underlying issue is that a quirk caused git to not be aware of the PATH.

j riv
  • 3,593
  • 6
  • 39
  • 54
2

See the config variable core.pager: "The command that git will use to paginate output. Can be overridden with the GIT_PAGER environment variable."

Wojtek Surowka
  • 20,535
  • 4
  • 44
  • 51
1

setting git core.pager will ensure log outputs directed to pager:

git config --global core.pager less
galactica
  • 1,753
  • 2
  • 26
  • 36