1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-05 16:18:01 +00:00

Add Turn Off The Output Pager For One Command as a git til

This commit is contained in:
jbranchaud
2021-02-01 18:09:01 -06:00
parent 9a6629b920
commit 1fcbe3dc46
2 changed files with 27 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
_1032 TILs and counting..._
_1033 TILs and counting..._
---
@@ -280,6 +280,7 @@ _1032 TILs and counting..._
- [Stashing Only Unstaged Changes](git/stashing-only-unstaged-changes.md)
- [Stashing Untracked Files](git/stashing-untracked-files.md)
- [Switch To A Recent Branch With FZF](git/switch-to-a-recent-branch-with-fzf.md)
- [Turn Off The Output Pager For One Command](git/turn-off-the-output-pager-for-one-command.md)
- [Two Kinds Of Dotted Range Notation](git/two-kinds-of-dotted-range-notation.md)
- [Unstage Changes Wih Git Restore](git/unstage-changes-with-git-restore.md)
- [Untrack A Directory Of Files Without Deleting](git/untrack-a-directory-of-files-without-deleting.md)

View File

@@ -0,0 +1,25 @@
# Turn Off The Output Pager For One Command
With `git` a pager, such as `less`, can be configured to display paginated
command output. There are many ways to set up the default pager such as setting
the `core.pager` value in your git-config or by setting the `$PAGER` env var.
Assuming it is set to something like `less`, you can view, scroll through, and
search the output of a command like `git log` or `git diff`. When you're
finished the pager will close, all the output will vanish, and you'll be back
at your terminal prompt.
This is generally a desirable workflow. If, however, you want to be able to
scroll back in your terminal history to reference a SHA or a commit message,
you'll be disappointed.
For one off commands where you know you'll want the output actually printed to
the terminal, you can turn off the pager with the `--no-pager` flag (or `-P` as
a shorthand).
```bash
$ git --no-pager show
```
This will print the details of the HEAD commit to the terminal. I can scroll
back and reference them as needed.