Search code examples
gitpager

How can I configure which CLI command is used to render the result of "git branch"?


When I run git branch on certain machines, I get a simple list of branches using what seems like the result of running the cat command.

However, especially on machines running ZSH, it seems like the result of git branch is resolved with the less command.

git branch
  • I expect direct output of local branches to stdout (like cat)
  • I am getting the output as if git branch is using less

So the question becomes: is there a way to configure which command is used to render the list of branches on the command line?

I feel like this is similar to setting the default editor (like nano or vim) via:

git config --global core.editor "nano"

Despite my best search efforts, I have not found a similar way to configure this for git branch.

The broader question is: How can one configure which tool a git command uses?


Solution

  • In this case, the config parameter you're looking for is core.pager. You can set that to the empty string (git config --global core.pager "") to disable pagination; this appears to be effectively the same as git config --global core.pager "cat". (You can also do this on a repo-by-repo basis, if you want, by omitting the --global.)

    If it's any help, I usually set mine to "less -FX", so that it gives me pagination when the output is longer than one terminal screen, but skips pagination on shorter inputs.