JamesWHurst
JamesWHurst

Reputation: 503

If you use the git diff command, how do you get out of that mess?

I'm trying to use Git, within a Git Bash terminal-window on MS Windows 8.1

When I enter: $git diff file1 to see the changes in a given file, it then presents me with a : prompt.

How does one get out of that mode, short of closing the whole terminal-window and starting over again? I tried CTRL-C (many times), etc. very annoying!

Thank you for any advice.

Upvotes: 8

Views: 4599

Answers (2)

Keith Thompson
Keith Thompson

Reputation: 263497

To get away from the : prompt, type q.

git diff, like many git commands, pipes its output through a pager by default. The default pager is typically less, and the less command uses : as its default prompt.

You should see the same thing for git log and so forth.

Type man less at your shell prompt to learn how to use the less command. Quick summary:

  • Space to go forward a page
  • b to go back a page
  • d to go forward half a page
  • u to go back half a page
  • up and down arrows (or k and j) to go up and down a line at a time
  • q to quit
  • h for help.

You can configure the less command (see the above mentioned man page for details). You can also configure which pager git users for commands that produce a lot of output if you'd rather not use less.

Personally, I have the $GIT_PAGER environment variable set to cat, so it effectively doesn't use a pager at all; I pipe it through less manually if I want to. But you might find it more convenient to let git do that for you.

Upvotes: 16

Ankit kaushik
Ankit kaushik

Reputation: 1063

To get out of the pager, one can press q.

In fact there are several other commands too, see the list here.

Upvotes: 4

Related Questions