30

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
  • 117,979
  • 135
  • 375
  • 532

4 Answers4

29

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
6

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
  • 114,841
  • 28
  • 237
  • 319
3

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

GIT_PAGER= git diff
pixelbeat
  • 29,113
  • 9
  • 48
  • 60