Search code examples
gitgit-branchmacos-high-sierra

macOS git branch displays branches in less


I'm running git version 2.16.1 under macOS High Sierra 10.13.3 and when I use git branch, the result is displayed through less. On the contrary, when I'm using git branch under Linux, the result is simply printed in stdout. How can I enforce git to work the same way it works in Linux?

git branch under macOS: git branch uses less in macos

git branch under Linux: enter image description here


Solution

  • This is a result of varying defaults for the pager.branch setting in your Git configuration.

    For a one-off pagerless git branch, run:

    $ git branch --no-pager
    

    To persistently disable the pager on a repo, run:

    $ git config --local pager.branch "cat"
    

    And if you want to set this globally, run:

    $ git config --global pager.branch "cat"
    

    The git-config docs outline this here.

    It should go without saying that if you ever want to revert to using less (or more, or whatever other pager), just replace cat with that other pager in the last two commands.