How do I prevent 'git diff' from using a pager?
--no-pager
to Git will tell it to not use a pager. Passing the option -F
to less
will tell it to not page if the output fits in a single screen.
Usage:
git --no-pager diff
Other options from the comments include:
# Set an evaporating environment variable to use 'cat' for your pager
GIT_PAGER=cat git diff
# Tells 'less' not to paginate if less than a page
export LESS="-F -X $LESS"
# ...then Git as usual
git diff
As a previous answer mentioned, passing the -F
option to less
causes it to quit if the content is less than one screen. However, after doing so, the screen is reset, and you end up not seeing the content.
The -X
option does away with that behaviour. So, I use the following to enable conditional paging based on the amount of content:
git config --global --replace-all core.pager "less -F -X"