How to make git diff write to stdout?

GitTerminal

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

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

Solution 2 - Git

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).

Solution 3 - Git

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

Solution 4 - Git

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

git --no-pager diff

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionnacho4dView Question on Stackoverflow
Solution 1 - GitmipadiView Answer on Stackoverflow
Solution 2 - GitfriederbluemleView Answer on Stackoverflow
Solution 3 - GitShasakView Answer on Stackoverflow
Solution 4 - GitstevecView Answer on Stackoverflow