Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Git list commands sometimes emulate a multi-page terminal, but I'd like output to always be dumped to stdout

I’m a little confused with the following behavior of git commands in the Windows Command prompt.

This shows a result comparable to VIM (I think) with interactive list

git branch -a

Result is something like the following and I’ve no idea what key-combinations to use to scroll through the output (I did notice that q ends the output).

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But this shows a "normal" result by just dumping the output to stdout

git show-ref --tags --heads

which is what I prefer:

enter image description here

How to make all output be just dumped to stdout?

I’d prefer if all commands work the same way. Esp if I want to automate a git command in a batch script or something, I cannot use some kind of interactive shell.

I noticed that this behavior seems to be caused by the TERM=msys environment variable setting, which, if absent, behaves the same. I don’t know if there’s a different setting I can use.

In the end, while the colored result may be fun, I can get that by using Git BASH. But when I run the commands directly from the Windows Command, I’d expect them all to just echo the output to stdout.

I can’t remember that this was the behavior previously, so my guess is that I installed something that f’ed things up ;). I’m on Windows 10 for this machine, git, bash etc are latest.

>Solution :

This is what git calls a pager. You can disable it for a particular command with:

git --no-pager branch -a

(Note that --no-pager goes between git and the subcommand, because it is a global switch).

If you want to configure your system so you don’t have to remember that, from man git-config:

pager.<cmd>

If the value is boolean, turns on or off pagination of the output of a particular Git subcommand when writing to a tty. Otherwise, turns on pagination for the subcommand using the pager specified by the value of pager.<cmd>. If --paginate or --no-pager is specified on the command line, it takes precedence over this option. To disable pagination for all commands, set core.pager or GIT_PAGER to cat.

That is, you can disable the pager for git-branch only with git config --global pager.branch false, for example.

And if you want to disable it for all commands do git config --global core.pager cat. Or you can try to set the environment variable GIT_PAGER=cat, of course.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading