42

When I run git diff on my OSX command line, the output is displayed inside a less or vim interface. The interface lets me to scroll up and down, and quit using the q key.

This is very annoying, especially when there is no diff and git opens a blank screen.

Can I just write the diff (color) output the the screen without entering the interactive mode?

Adam Matan
  • 128,757
  • 147
  • 397
  • 562

4 Answers4

43

Disable the interactive pager with the --no-pager option.

Usage: git --no-pager diff (note how it's not specific to git-diff, so it's usable with any git command!)

Documentation: https://git-scm.com/docs/git

Copied from https://stackoverflow.com/a/2183920/2221472

16

You can also use:

git diff --exit-code
Manveer Chawla
  • 404
  • 2
  • 6
7

Yes. Use:

git diff --color | cat

The --color is necessary, since by default git will not output colors if stdout is not a tty (with color support).

fge
  • 119,121
  • 33
  • 254
  • 329
4

I use this in some Makefiles with 'diff' and 'grep':

GIT_PAGER= git diff
pixelbeat
  • 30,615
  • 9
  • 51
  • 60