136

By default git diff prints all +- lines to the stdout however I have a (devian) machine (which I connect through ssh) where git diff leads me to an editor (which I don't know which is) and I need to press q to continue.

I've checker git config and it looks like :

$ git config --list
user.name=XXX
user.email=XXX@XXX
color.ui=false
difftool.prompt=false
mergetool.prompt=false
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=XXX
branch.master.remote=origin
branch.master.merge=refs/heads/master
$ git config --global --list
user.name=XXX
user.email=XXX@XXX
color.ui=false
difftool.prompt=false
mergetool.prompt=false
$ git config --system --list
'/etc/gitconfig': No such file or directory

Is there a place I am missing? Maybe the unknown tool is a fallback or something because I my machine is missing something? Any help is appreciated. Thanks.

nacho4d
  • 41,605
  • 42
  • 154
  • 237

4 Answers4

223

By default, Git sends its diff output (and generally any output that may be more than a screenful) to the system's pager, which is a utility that prints only one screenful of output at a time. If you want to disable the pager when you run a command, pass --no-pager to Git:

$ git --no-pager <subcommand> <options>

This can be run for any Git command.

If you want to disable it by default for diff only, you can set the diff pager to cat by running:

$ git config pager.diff false

If you want to disable it by default for all commands, you can set the Git pager to cat by running:

$ git config --global core.pager cat
mipadi
  • 380,288
  • 84
  • 512
  • 473
39

The following core.pager value uses less, which prints to stdout, and also has pager functionality (if required), enabling scrolling up and down (unlike cat):

$ git config --global core.pager "less -FRSX"

It immediately quits if the diff fits on the first screen (-F), outputs raw control characters (-R), chops long lines rather than wrapping (-S), and does not use termcap init/deinit strings (-X).

friederbluemle
  • 28,615
  • 14
  • 96
  • 99
32

You can also simply use cat for any git command if you don't care about the colors.

So git diff | cat for your case.

Edit: as pointed out in the comments if you do care about the colors use:

git diff --color | cat

Shasak
  • 740
  • 7
  • 18
-1

As @mipadi points out, It's this simple:

git --no-pager diff
stevec
  • 27,285
  • 13
  • 133
  • 181
  • Re: the delete vote. I made this answer because it's actually incredibly simple question which *doesn't need* a long answer. That's not at all to say that a long answer is not appreciated (I upvoted 2 of the 3 existing answers, because they were great). I just felt a simple answer is sometimes what people need; hence I provided one. – stevec Jan 20 '22 at 02:43
  • I assume the delete vote is because this answer is almost identical to the beginning of the most upvoted and accepted one. Yes, this one gives the quick and exact command, while the other one gives only the more general command, but maybe some attribution wouldn't hurt, otherwise it might look like a copy+paste answer. – Cristik Jan 20 '22 at 06:28
  • @Cristik good points. I will make an amend shortly – stevec Jan 20 '22 at 06:30