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 highlightinggit 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.
To exit this you can use: :q for exit; :h for help; Note: if you don't want to read the output in pager you can use an ENV variable GIT_PAGER to cat or you need to set core.
answered Jul 18, 2019 by debashis borgohain (27.5k points) --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.
The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.
Diff command is used in git to track the difference between the changes made on a file. Since Git is a version control system, tracking changes are something very vital to it. Diff command takes two inputs and reflects the differences between them. It is not necessary that these inputs are files only.
--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
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