【问题标题】:How can I repress the output of `git-count-objects` when invoking `git-push`?调用`git-push`时如何抑制`git-count-objects`的输出?
【发布时间】:2021-11-27 04:48:09
【问题描述】:

我认为git-push 的输出非常冗长:

$ git push 
Enumerating objects: 36, done.
Counting objects: 100% (36/36), done.
Delta compression using up to 8 threads
Compressing objects: 100% (23/23), done.
Writing objects: 100% (26/26), 2.45 KiB | 1.23 MiB/s, done.
Total 26 (delta 19), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (19/19), completed with 8 local objects.
To github.com:DataBiosphere/azul.git
 + 541326b5...69385318 issues/noah-aviel-dove/3372-implicit-source-filter-circumvented -> issues/noah-aviel-dove/3372-implicit-source-filter-circumvented

我觉得这个输出中唯一有趣或有用的部分是:

  • 我要推送到的远程存储库的名称
  • 远程分支的名称
  • 当地分支机构的名称
  • (不包括在上面的示例中)任何错误消息或警告

根据this answer,剩下的输出来自git-count-objects

我认为这种额外的输出是对屏幕空间的干扰和阻碍性浪费。 我正在寻找一种方法来改变 git-push 的行为,从而完成两件事:

  1. 抑制或减少git-count-objects 的输出
  2. 不要不要隐藏我认为有用的输出元素(上面列出的所有要点)。

--quiet 标志不符合我的第二个标准。还有其他方法可以更好地控制git-push 的输出吗?

【问题讨论】:

    标签: git output git-push verbosity


    【解决方案1】:

    我的工作解决方案是将 git-push 别名为运行的 bash 脚本:

    git push --dry-run $@ && git push --quiet $@;
    

    由于在实际未发送对象时不会打印已发送对象的统计信息。这会产生输出:

    $ git push
    To github.com:DataBiosphere/azul.git
       e324c486..9990e272  issues/noah-aviel-dove/3372-implicit-source-filter-circumvented -> issues/noah-aviel-dove/3372-implicit-source-filter-circumvented
    

    这是理想的。但是,git-push 的双重调用会引入少量但明显的延迟。可能存在避免这种情况的更好解决方案。

    【讨论】:

    • 您是否尝试使用|while read 来清除默认的git push 输出?
    • @fluffy 我考虑过这种方法,但认为它很脆弱,因为我不确定可能还有其他我尚未观察到的输出格式。对于输出不打算以编程方式解析的程序的管道,我通常非常谨慎。虽然如果你有这种方法的工作示例,我很想看看。
    • 没有,很遗憾没有。我在git push 输出中没有看到任何真正令人讨厌的东西——至少它清楚地表明正在发生一些事情。但是,我没有检查您的双命令方法,但它不是也抑制了远程消息吗?
    猜你喜欢
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-29
    • 2010-10-31
    • 2016-10-03
    • 2011-05-23
    相关资源
    最近更新 更多