gitpager

Turning off the pager in git by default


Turning off the pager in git for the stash command only and Disable all paging in git doesn't answer to this question because I sometimes want use the pager, but not by default, I just want git use pager when I add -p option

Update 2021-02-11 , one partial solution, I think that can do in some pieces, for example for branch command:

git config --global pager.branch false

Update 2022-06-15 for me the best solution but -p will not work:

git config --global core.pager ""

2022-06-15 : as I use a terminal with scroll bar , seems for me that will be more productive limit the entries of output than put in pager , for me instead write in terminal (I use konsole) for here I can copy, paste and search . If output goes to a pager the output will be lost forever when we leave the pager

Now just need to find out, how I limit the results to 100 or 200

I mean git log by default be git log -100

in conclusion Git doesn't offer an option to do this , so this question falls in Disable all paging in git


Solution

  • Git doesn't offer an option to do this, so you have a couple of options:

    git () {
        local pager=""
        
        for arg in "$@"
        do
            [ "$arg" = "-p" ] && pager="-c core.pager=less"
        done
    
        command git $pager "$@"
    }