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?
Use ONLY q+enter to exit. It's possible to break out by repeatedly typing q+enter+q+enter+q+enter until the end of time no matter what the console shows.
In most cases, Git picks A and B in such a way that you can think of A/- as "old" content and B/+ as "new" content. Let's look at our example: Change #1 contains two lines prepended with a "+". Since no counterpart in A existed for these lines (no lines with "-"), this means that these lines were added.
Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
Git uses pager when you run git diff , git show , git grep etc. If you want to see the result without pager, just add --no-pager or -P .
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With