Is there a command line switch to pass to git diff and other commands that use the less pager by default? I know these methods exist:

  • git diff | cat… removes all syntax highlighting
  • git config --global core.pager cat sets the pager in the global .gitconfig to cat
  • export GIT_PAGER=cat

But I would prefer a command line switch.

18 s
18

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

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *