148

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
  • 43,720
  • 45
  • 157
  • 240

4 Answers4

241

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
  • 398,885
  • 90
  • 523
  • 479
46

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
  • 33,549
  • 14
  • 108
  • 109
36

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
  • 790
  • 8
  • 19
1

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

git --no-pager diff
stevec
  • 41,291
  • 27
  • 223
  • 311