git log -{n}, when -n is sufficiently small, doesn't open in less it simply prints it to the screen. That's desirable. git log -1 should not take up the full screen.

Unfortunately, in MINGW's bash shell, after I've run a non-git command, git log behaves as if I had ran it into less and pushed q. (in otherwords the data is printed to the bottom of the screen and I wind up with a pile of whitespace on top).

Imaginary demo (Please forgive its length):

>> clear

>> git log -1

commit 123123...
Author: CPfohl
Date: {today}

>> git log -1
commit 123123...
Author: CPfohl
Date: {today}

This works no matter what git command I execute before git log, as long as git log -{n} is after a git command.

Is this a bug, or is there a way to get this to behave normally?

2 Answers 2


If you want to disable pagination for some/all git commands you can:

  • set configuration value (pager.<cmd> or core.pager for all commands) to cat
  • use --no-pager option

But maybe I haven't understood your question. Described behaviour should be possibly altered by setting appropriate pagination command (less with some options) in aforementioned configuration options.

  • What if I only want to do this when runing git log with an -n option? Nov 18, 2011 at 21:24
  • You may try to add command alias (including -n option) and for that alias use pager.alias_name = less .... But I don't know if the alias can be used as a comand in mentioned configuration option. Nov 18, 2011 at 21:33
  • 5
    --no-pager option works like a charm! But seems like --no-pager needs to be supplied before "log" for it to work. You should update the answer to clarify this. "git log ... --no-pager" doesn't work, while "git --no-pager log ..." does.
    – CoolMcGrrr
    Jun 22, 2016 at 7:13

Or you could also define an alias in your git config file that allows you to show the log in a special way, if you enter the following commands for example you set up .gitconfig to be edited with Sublime Text 3:

git config --global core.editor "'c:/Program Files/Sublime Text 3/sublime_text.exe'" -w

git config --global alias.showconfig "config --global -e"

Further you can then add an alias in git to show you the latest commits accross all branches in a repository:

Add [alias] if missing in .gitconfig, then:

latest = "!f() { echo "Latest \"${1:-11}\" commits accross all branches:"; git log  --abbrev-commit --date=relative --branches --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' -n ${1:-11};  } ; f"

The alias here uses a shell function with a parameter set to a shell variable. If you do not specify a parameter value, the alias will use 11 as the default value (The syntax could easily be interpreted with -11, but the syntax ${1:-11} means the first parameter in the shell and setting a default value for the parameter if it is missing. A bit like default values in C# or default parameters in Powershell.

As you can see, the alias we give to git can contain multiple commands, separated by a semi-colon.

I tried this out by running git latest and git latest 3 in the sample output screen grab below. You see my edit of my git config to the left.

With shell functions and aliases we can do much more with Git without having to type so much. The syntax of shell-functions follows BASH rules and can be used also in a Windows environment with CMD.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .