tags:

views:

110

answers:

5
git log -n 20 --pretty=oneline

I am telling git that I need to see only last 20 commits. I hate to hit Q to get rid of END. Is there a way out so that I don't have to hit q.

A: 

the q is used to close the command line program used to view the logs... you can use another log viewer like gitk

gitk -n 20
Ahmed Kotb
gitk is useful to view graphs etc. I was looking for a lightweight solution. thanks.
Nadal
+11  A: 

Git is automatically paging the output for you, since logs tend to easily overflow a single terminal window size (you're in one of the rare exceptions - a oneline format and a small commit limit). If you don't want this, use:

git --no-pager log -n 20 --pretty=oneline

Note that this does mean you'll get some ugly wrapping, because the pager was previously turning off wrapping for you (since you could use the cursor keys to scroll left-right).

Jefromi
it's actually a nice feature of git to automagically use the pager, but thanks for the tip on how to tell it not to.
alesplin
Agreed, that was the thought behind my first sentence. The behavior is generally very intelligent.
Jefromi
+1  A: 

git log -n 20 --pretty=oneline | cat

is a little shorter that the --no-pager option but will also remove any colours present.

Debilski
If you want short, alias it. No need to sacrifice features!
Jefromi
+2  A: 

You can "turn off" git paging by telling it to use cat instead of less. Thereafter, pipe the output through less when you do want paging, or head if you just want to see the top, etc.

git config --global core.pager cat

I turn off automatic paging because I often run git from within emacs, which neither needs not plays well with less.

Wayne Conrad
A: 

less accepts -F argument to quit automatically if content fits on one screen

hasen j