1278

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:

Git log shows (END) marker

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?

Arsen Khachaturyan
  • 7,904
  • 4
  • 42
  • 42
Wern Ancheta
  • 22,397
  • 38
  • 100
  • 139
  • 15
    Even after I use q+Enter to quit, the reappears every time I begin typing again. It eats up my first character. Thereafter, I'm able to type the command I want. However, I'd rather not have this behavior at all. I'm on Windows. Suggestions? – Puneet Lamba Nov 09 '14 at 17:10
  • 12
    Windows users: you must type q+enter first. Once you escape with cntl+c, you'll be stuck in that weird loop. Use ONLY q+enter to exit. – STWilson Nov 25 '16 at 17:31
  • 2
    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. – vinczemarton Mar 14 '17 at 10:36
  • I fixed it by using another console, typing "ps" to find all the processes, then typing "kill -9 " to kill less. Nothing else worked. – Kiki Jewell Jan 24 '19 at 02:03
  • just press ( :qa ) without parentheses and hit Enter, it will exit. – Mohamed AbdelraZek Sep 17 '19 at 12:05
  • @KodiakMx brought me here too but its seven years after ptkvsk and 43 other users agreed with him – Dave Pile Jul 23 '21 at 05:19
  • Usually you just curse and then close the window, the answers below provide better options though – Peter Chikov Aug 30 '23 at 18:49

7 Answers7

1949

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).

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
141

Actually, there are three ways to do it, precisely.

Type any of the following 3 commands.

  1. :q
  2. :z or
  3. Ctrl + z

P.S.: Sometimes, for someone, one of these options doesn't seem to work and for others it works.

robbieperry22
  • 1,753
  • 1
  • 18
  • 49
shrexchauhan
  • 1,537
  • 1
  • 9
  • 8
54

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
J4cK
  • 30,459
  • 8
  • 42
  • 54
  • 4
    `git --no-pager` is a thing I was looking for, thanks! – Zapko Jul 04 '17 at 19:57
  • You can also do `GIT_PAGER=cat git diff` to use `cat` temporarily, or, alternatively to this, save it in your shell environment. – taco Apr 07 '20 at 20:36
50

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.

seanhodges
  • 17,426
  • 15
  • 71
  • 93
36

The END comes from the pager used to display the log (your are at that moment still inside it). Type q to exit it.

Benjamin Bannier
  • 55,163
  • 11
  • 60
  • 80
11

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.).

Jeremy
  • 131
  • 1
  • 4
  • 1
    I wouldn't have considered using a graphical program such as Notepad with one like Git that runs in a terminal. – David A. Gray Feb 24 '21 at 17:54
  • 1
    Ctrl-Z on Unix-like platforms leaves the process present but stopped; this only makes sense on Windows (to the extent that anything at all makes sense on Windows). – tripleee Oct 16 '22 at 13:00
7

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).

HelloGoodbye
  • 3,624
  • 8
  • 42
  • 57