سؤال

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?

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

You can also use:

git diff --exit-code

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

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

GIT_PAGER= git diff
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top