Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git error: cannot spawn more: No such file or directory

Tags:

git

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.

like image 414
桔子214032 Avatar asked Jan 01 '23 06:01

桔子214032


2 Answers

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.

like image 167
torek Avatar answered Jan 05 '23 07:01

torek


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.

like image 41
c z Avatar answered Jan 05 '23 08:01

c z