Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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.

like image 884
JamesWHurst Avatar asked Mar 01 '15 09:03

JamesWHurst


People also ask

How do I come out after git diff?

Use ONLY q+enter to exit. It's possible to break out by repeatedly typing q+enter+q+enter+q+enter until the end of time no matter what the console shows.

What does git diff command do?

Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.

Does git diff show all changes?

The git diff command returns a list of all the changes in all the files between our last commit and our current repository. If you want to retrieve the changes made to a specific file in a repository, you can specify that file as a third parameter.


2 Answers

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.

like image 143
Keith Thompson Avatar answered Nov 15 '22 08:11

Keith Thompson


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

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

like image 28
Ankit kaushik Avatar answered Nov 15 '22 07:11

Ankit kaushik