如何在 Git 别名中包含 --no-pager?
我根据 EdgeCase 的 Git Immersion 教程创建了一个 Git 别名,如下所示:
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
但现在看来对结果进行分页 — 结果显示后,终端显示 (END)
,迫使我点击 Q 继续工作。我读到,通过添加 --no-pager
标签,您可以禁用此功能;如何将其合并到别名中?我在最后、日志之前和之后都尝试过,但没有一个起作用。 Git 会抛出错误,指出它是无法识别的参数,或者它更改了环境变量。有什么建议吗?
I created a Git alias based off of the Git Immersion tutorial by EdgeCase that looks like this:
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
But now it seems to be paging the results — Terminal shows (END)
after the results are displayed, forcing me to hit Q to continue working. I read that by adding in the --no-pager
tag, you can disable this feature; how do I incorporate it into the alias? I've tried it at the end, before the log
, and right after, and none of them have worked. Git throws an error saying it is an unrecognized argument, or that it changes environment variables. Any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您只需将其转换为 shell 命令即可轻松完成此操作:
You can do that easily by just turning it into a shell command:
注意:在 Git 2.18(2018 年第 2 季度)中,别名可以使用更短的
--no-pager
选项:“
git --no-pager cmd
”没有简短而甜蜜的单字母选项。现在确实如此。别名现在可以是:
请参阅 commit 7213c28(2018 年 5 月 3 日),作者:Johannes Sixt (
j6t
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 c9aac55,2018 年 5 月 23 日)Note: with Git 2.18 (Q2 2018), the alias can use a shorter option for
--no-pager
:"
git --no-pager cmd
" did not have short-and-sweet single letter option. Now it does.The alias can now be:
See commit 7213c28 (03 May 2018) by Johannes Sixt (
j6t
).(Merged by Junio C Hamano --
gitster
-- in commit c9aac55, 23 May 2018)--no-pager 选项在
log
之后使用时会出现无法识别的选项
错误,但它可以通过将 --no-pager 放在 log 之前来实现 - “git --no-寻呼机日志......“有效The --no-pager option gives an
unrecognized option
error when used afterlog
, but it worked by putting --no-pager before log - "git --no-pager log .... " worked