当我使用git branch命令列出所有分支时,我看到git branch | less的输出。

命令git分支应该显示一个分支列表,就像ls显示文件一样。

这是我得到的输出:

我如何得到git分支的默认行为?是什么导致了分页输出?

我的.gitconfig是这样的:

[user]
  email = myemail@mail.com
  name = Dennis H.
[push]
  default = simple
[merge]
   tool = vimdiff
[core]
  editor = nvim
  excludesfile = /Users/dennish/.gitignore_global
[color]
  ui = true
[alias]
  br = branch
  ci = commit -v
  cam = commit -am
  co = checkout
  df = diff
  st = status
  sa = stash
  mt = mergetool
  cp = cherry-pick
  pl = pull --rebase
[difftool "sourcetree"]
  cmd = opendiff \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
  cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh 
  \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
  trustExitCode = true

当前回答

对于那些想要更新~/。Gitconfig来修复这个问题,它看起来像这样:

[pager]
   branch = false

其他回答

https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables

GIT_PAGER控制用于在上显示多页输出的程序 命令行。如果未设置该参数,则将使用PAGER作为备用。

要解决这个问题,可以在shell中取消设置PAGER和GIT_PAGER。

不是在语义上争论,而是你得到的行为是默认的。这就是为什么当你不要求不同的东西时,你会得到它。默认情况下,分支(以及许多其他Git命令)在向终端发送输出时使用分页器。

你可以使用——no-pager选项来覆盖这个默认值:

git --no-pager branch

或者,如果您将输出重定向到一个文件,Git应该检测到它没有写入到终端,因此无论如何都不应该使用寻呼机。(另一方面,这建议使用脚本用例,在这种情况下,您应该考虑使用像git for-each-ref这样的管道命令,而不是git分支。)

做以下几点:

[alias]
  br = !git --no-pager branch

正如Mark Adelsberger回答的评论中提到的,这是Git 2.16中引入的默认行为更改。

在默认情况下,您可以使用分页器关闭git分支的分页输出。分支配置设置:

git config --global pager.branch false

对于那些想要更新~/。Gitconfig来修复这个问题,它看起来像这样:

[pager]
   branch = false