Git Ignore Full Page Output When Content Fits Screen
15 October 2022 | 2 min read | git
Git utilizes the default less pager program to display command outputs such as git
log
, git diff
, or git branch
. The less pager is an efficient tool that reads large files page by page or screen size, without loading the
entire content into the computer’s main memory. This approach enhances performance and responsiveness, especially when dealing with
extensive data.
The benefits of using less become particularly apparent when handling commands like git log or git diff. When the content being displayed is
smaller than a full page, you’ll appreciate the streamlined output, which ensures that your terminal screen remains clutter-free and easy to
navigate. This optimized user experience is one of the reasons why less is the go-to pager for Git’s command output presentation.
As in the above gif, we can avoid the full page output when content fits screen by passing the flag -F with less command,
where -F causes less pager to exit
if entire file can be displayed on first screen. Here is the git configuration command for it.
git config --global core.pager "less -F"
And that’s pretty much all !!