How to exit git log or git diff
GitGit DiffGit LogGit Problem Overview
I'm trying to learn Git with the help of Git Immersion.
There's one thing that frustrates me whenever I use git log
or git diff
:
I can't figure out what to do next when I encounter this (END)
word.
I can't type any commands, and I end up closing the current Bash window and open another. How do I type in the next command that I want to use?
Git Solutions
Solution 1 - Git
You're in the less
program, which makes the output of git log
scrollable.
Type q to exit this screen. Type h to get help.
If you don't want to read the output in a pager and want it to be just printed to the terminal define the environment variable GIT_PAGER
to cat
or set core.pager
to cat
(execute git config --global core.pager cat
).
Solution 2 - Git
Actually, there are three ways to do it, precisely.
Type any of the following 3 commands.
- :q
- :z or
- Ctrl + z
P.S.: Sometimes, for someone, one of these options doesn't seem to work and for others it works.
Solution 3 - Git
You can press q to exit.
git hist
is using a pager tool so you can scroll up and down the results before returning to the console.
Solution 4 - Git
Add following alias in the .bashrc file
git --no-pager log --oneline -n 10
--no-pager
will encounter the (END) word-n 10
will show only the last 10 commits--oneline
will show the commit message, ignore the author, date information
Solution 5 - Git
The END
comes from the pager used to display the log (your are at that moment still inside it). Type q to exit it.
Solution 6 - Git
I wanted to give some kudos to the comment that mentioned CTRL + Z as an option. At the end of the day, it's going to depend on what system that you have Git installed on and what program is configured to open text files (e.g. less vs. vim). CTRL + Z works for vim on Windows.
If you're using Git in a Windows environment, there are some quirks. Just helps to know what they are. (i.e. Notepad vs. Nano, etc.).
Solution 7 - Git
In this case, as snarly suggested, typing q is the intended way to quit git log
(as with most other pagers or applications that use pagers).
However normally, if you just want to abort a command that is currently executing, you can try ctrl+c (doesn't seem to work for git log
, however) or ctrl+z (although in bash, ctrl-z will freeze the currently running foreground process, which can then be thawed as a background process with the bg
command).