When using git diff, what is this "s" command and how do I cancel it?

Viewed 69

Occasionally when I use git diff (in Windows command prompt), instead of hitting w to go up a page, I accidentally hit s and get the prompt:

log file:

No matter what I press to try to escape from this prompt (Esc, Ctrl-C, Ctrl-Break), my terminal session is never quite right afterwards, and eventually I have to kill it and start over.

How can I cancel this prompt without having to restart my terminal session?

And what is this prompt for anyway?

3 Answers

Git calls a terminal pager that defaults to less for displaying long content.

From man 1 less, section COMMANDS:

   s filename
          Save the input to a file.  This only works if the input is
          a pipe, not an ordinary file.

Next time when you're stuck right here, just hit Enter and you'll be clear of it.

Backspace works for me, but I am trying this on Linux and Ctrl+C works as well, not quite sure about Windows

When the output of the diff is longer than one page (i.e. has more lines than can be displayed on the terminal without scrolling), Git uses the pager you have configured to break the output into pages.

Any interaction would be with the pager you configured. You would have to defer to the manual for your pager to see what the s command does.

This is not Git-specific, but standard operating procedure in *nix-style operating systems. Rather than having every program re-implement this functionality, and to give users flexibility in configuring how they want their system to behave, paging is handled by a separate utility program.

The Git manual discusses the pager here, in the section describing the core.pager configuration option.

Related