git branch
命令列出所有分支时,我看到了git branch | less
的输出结果。这个命令应该像ls
一样列出所有分支。
以下是我得到的输出截图。
如何恢复git branch
的默认行为?是什么导致了分页输出?
我的.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
git branch
与其他命令链式使用。使用管道检测(pipe detection),Git会将分支列表输出到标准输出中,在命令git branch > branches.txt
或git branch | wc -l
中都可以实现。 - Rory O'Kaneless
,则可以将--no-init --quit-if-one-screen
添加到您的LESS
环境变量中,这将导致less
仅在文本无需滚动即可查看时才写入标准输出。有关更多详细信息,请参见man less
。 - Rory O'Kane[pager] branch = false
(分成两行)。 - Samexport LESS="--no-init --quit-if-one-screen -R"
(包括 -R),以便支持原始颜色控制字符。否则,你的 git log 会受到影响。 - joseph