11

When I execute the git branch command, the following happens (using PowerShell on Windows 10):

> git branch
error: cannot spawn more: No such file or directory
  develop
* feat/sticky

This does not seem to prevent Git from functioning normally, but I am curious as to why this error happens.

4 Answers 4

8

It looks like you have configured your Git to use the command more as your pager. But the command more does not exist, so when Git tries to use it, that fails; the consequence is that your Git runs without a pager, as if you had run git --no-pager branch instead of just git branch.

Pagers

The concept of a pager goes back to the days of non-window-system computer terminals, that just showed, e.g., 24 lines of text at a time, typically with a maximum of 80 columns of ASCII or similarly restricted characters (nothing fancy like ¡Hola!, ¿que?). If you can only show 24 lines, but have 30 branch names to show, how will you deal with that?

Modern window systems have scroll-bars and the like, but we still exist in a world where showing one "page" of output at a time is useful. A pager will adapt text to fit your window, one page at a time. Popular pagers these days include less, which is like more but fancier (see its Wikipedia article). A good pager can also search and highlight, which means that if any built in search and/or highlight of some command isn't good enough—or is nonexistent—just running that command's output through the pager augments the command so that it now has very fancy search and highlight.

Some systems now come with a more program that is literally just a mode of less. See also this SuperUser post about more and less.

1
  • The command more does exist on Windows. Commented Aug 7 at 22:10
7

On Windows, use:

git config --global core.pager ""

Because the Windows terminal supports vertical and horizontal scrolling by itself.

The default of more is more useful on older Linux terminals (without horizontal scrolling) or terminals from the 1980s, that didn't have any scrolling. However, it also stops your window being filled up with junk, so even some Windows distributions apply it. They probably shipped with a terminal emulator supporting more, but then you get this error when you use git outside that terminal. You could find a more.exe (e.g. from Cygwin) and set the path to that if you really want to use it.

4

@c-z's Windows solution didn't work for me, but

git config --global core.pager '""'

did the trick.

3

Try this, it works for me:

git config --global core.pager '\"C:\Windows\System32\more.com\"'
2
  • 4
    This worked without the surrounding escaped doublequotes \"
    – Aaron_H
    Commented Oct 6, 2023 at 0:22
  • git config --global core.pager '%WINDIR%\System32\more.com' Commented Aug 7 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.