38

I like having the pager enabled for git log for example, but not git diff because I have my own visual diff tool that comes up, and I hate having to hit 'q' at the command line after the diff is done with. Is there a way to do this?

2

3 Answers 3

52

You can set the pager.diff configuration variable to disable the pager for specific subcommands. See pager.<cmd> in git-config(1).

git config --global pager.diff false

Leave out --global if you only want to make this configuration change for the current repository.

3
  • 7
    To disable for a particular invocation: git -c pager.diff=false log ....
    – mjs
    Oct 5, 2016 at 14:00
  • 2
    @mjs I think an easier way is git -P diff. See -P docs Apr 18, 2022 at 16:41
  • 1
    and likewise, pager.branch works for git branch Dec 5, 2023 at 20:36
8

Just add | cat to the end of your git call. This will trick git into dumping the whole thing as standard output (because no longer interactive).

e.g.

git diff --stat | cat

Sadly, you'll lose the color in your output, as a side-effect, but you can force it on by adding --color before the | cat, yielding:

git diff --stat --color | cat
1
  • 1
    Works like a charm, thanks. It might not be the most systematic way, but some times quick and dirty does it. Sep 16, 2022 at 11:36
-1

Not a great solution, but you could have a git wrapper which determines what command you are running and pipes the output through cat to eliminate the terminal detection.

#!/bin/sh
case "$1" in)
  diff) git "$@" | cat;;
  *) exec git "$@";;
esac

Of course my example program is entirely braindead. You would need to skip over options instead of hard-coding "$1" in the program.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .