只关闭存储命令的git中的寻呼机 [英] Turning off the pager in git for the stash command only

查看:128
本文介绍了只关闭存储命令的git中的寻呼机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一般都喜欢在git中使用寻呼机,但是对于 git stash 寻呼机让我感到困扰。当调用 git stash list 时,我不希望在寻呼机中显示三行输出 - 它迫使我按 q 只是为了在输入以下内容时再次使输出不可用: git stash pop 命令。

I generally like the use of the pager in git, but for git stash the pager annoys me. When calling git stash list, I don't want to be shown the three lines of output in the pager -- it forces me to press q just to make the output unavailable again when typing the folow-up git stash pop command.

一个解决方案是使用

One solution would be to use

git --no-pager stash list

但是这很多打字(我很懒)。遵循手册页 git config ,我试过了

but that's to much typing (I'm lazy). Following the man page of git config, I tried

git config --global pager.stash false

但这似乎没有做文档所说的(实际上,我没有注意到任何影响)。然后我尝试了

but this doesn't seem to do what the documentation says (actually, I didn't notice any effect). Then I tried

git config --global alias.stash "--no-pager stash"

再次没有任何明显的影响。

again without any noticable effect.

配置得到正确更新,例如

The configuration gets properly updated, for example

git config pager.stash
false

它没有任何效果。我错过了什么?我该如何实现 git stash 不使用寻呼机?

It just does not have any effect. What am I missing? And how can I achieve that git stash does not use the pager?

推荐答案

它看起来像隐藏,其他任何非内建命令(写成shell脚本,而不是C)都会在寻呼机配置步骤中遗漏。我向git邮件列表发送了一个笔记,询问这个问题;它看起来像是一个已知问题,但并不是完全无关紧要的。

It looks like stash, and any other non-builtin command (written as a shell script, rather than in C) misses out on the pager config step. I sent a note to the git mailing list asking about this; it looks like it's a known issue, but not totally trivial to fix.

你认为别名没有影响的主要原因是git默默地忽略了构建的别名-in命令;这个想法是,你永远不想让一个命令无法访问。为了让别名有机会运行,您需要将其命名为 stash

The primary reason you're seeing no effect from your alias is that git silently ignores aliases for built-in commands; the idea is that you never want to actually make a command inaccessible. For the alias to have a chance of being run, you need to name it something other than stash.

以外的其他名称,我相信简单的别名不允许影响运行git命令的环境,它通常包括传递给 git 本身的选项。如果我使用像你这样的别名:

However, I believe that simple aliases are not permitted to affect the environment a git command is run in, which generally includes the options passed to git itself. If I use an alias like yours:

git config alias.foo --no-pager stash
git foo
fatal: alias 'foo' changes environment variables

如果你想正确地做到这一点, '必须使用!git --no-pager stash ,这样它会产生一个子shell并重新启动git。

If you want to do that properly, you'd have to use !git --no-pager stash, so that it'll spawn a subshell and reinvoke git.

另一个临时修复,因为它是一个shell脚本,将直接编辑 libexec / git-core / git-stash 。只要找到 list_stash 函数,并将 - no-pager 选项添加到 git log ,或覆盖整个脚本,在顶部设置 GIT_PAGER = cat

Another temporary fix, since it's a shell script, would be to go edit libexec/git-core/git-stash directly. Just go find the list_stash function, and add the --no-pager option to its call to git log, or to cover the whole script, set GIT_PAGER=cat at the top.

这篇关于只关闭存储命令的git中的寻呼机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆