Git配置命令输出调整显示方式

场景

使用git branch查看所有分支时,发现git是以分页的形式显示的,当对分支名进行操作复制粘贴时非常不方便:

希望将指令输出内容改成直接输出到终端显示:

解决方法

使用帮助手册命令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.

那么使用以下命令git config --global pager.xxx false就可以将命令输出改为输出到终端:

git config --global pager.branch false # git branch 以打印到终端显示
git config --global pager.branch true  # git branch 在终端中分页进行显示

# 其他
git config --global credential.helper store # 存储用户名和密码 下次免输入
git config --system --unset credential.helper # 不存储用户名密码 每次提交和拉取都需要输入

参考文章

[1] git branch 不单独输出在终端

posted @ 2020-11-14 10:39  Macrored  阅读(876)  评论(0编辑  收藏  举报