繁体   English   中英

如何缩短'git pull'命令的输出?

[英]How to shorten output of 'git pull' command?

  • 所以我在git仓库上运行了$ git pull命令。
  • 它会输出我感兴趣的有用细节以及许多我不在乎的细节。
  • 那么,是否有一些切换或选项只保留我需要的细节?

$ git pull

需要以下信息:

remote: Enumerating objects: 2866, done.
remote: Counting objects: 100% (2866/2866), done.
remote: Total 4840 (delta 2865), reused 2865 (delta 2865), pack-reused 1974
Receiving objects: 100% (4840/4840), 7.51 MiB | 2.98 MiB/s, done.
Resolving deltas: 100% (3810/3810), completed with 531 local objects.
From https://github.com/erlang/otp
   76da23bb4e..6053c0e4d7  master     -> origin/master
   77cff66931..39968f062e  maint      -> origin/maint
   934f9974eb..f30b1052c7  maint-21   -> origin/maint-21
 * [new tag]               OTP-21.2.6 -> OTP-21.2.6
 * [new tag]               OTP-20.3.2.1 -> OTP-20.3.2.1
Updating 76da23bb4e..6053c0e4d7

不需要此信息:

Fast-forward
 .gitignore                                         |     3 +
 bootstrap/bin/no_dot_erlang.boot                   |   Bin 6539 -> 6541 bytes
 bootstrap/bin/start.boot                           |   Bin 6539 -> 6541 bytes
 bootstrap/bin/start_clean.boot                     |   Bin 6539 -> 6541 bytes
 bootstrap/lib/compiler/ebin/beam_a.beam            |   Bin 3364 -> 3200 bytes
 bootstrap/lib/compiler/ebin/beam_asm.beam          |   Bin 11040 -> 10996 bytes
 bootstrap/lib/compiler/ebin/beam_block.beam        |   Bin 3460 -> 3444 bytes
 bootstrap/lib/compiler/ebin/beam_disasm.beam       |   Bin 20864 -> 20860 bytes
 bootstrap/lib/compiler/ebin/beam_except.beam       |   Bin 4252 -> 4228 bytes
 bootstrap/lib/compiler/ebin/beam_jump.beam         |   Bin 10024 -> 9988 bytes
 .../lib/compiler/ebin/beam_kernel_to_ssa.beam      |   Bin 29484 -> 28880 bytes
 bootstrap/lib/compiler/ebin/beam_peep.beam         |   Bin 3644 -> 3604 bytes
 bootstrap/lib/compiler/ebin/beam_ssa.beam          |   Bin 12208 -> 12176 bytes
 bootstrap/lib/compiler/ebin/beam_ssa_bsm.beam      |   Bin 18176 -> 17952 bytes
 bootstrap/lib/compiler/ebin/beam_ssa_codegen.beam  |   Bin 37824 -> 37708 bytes
 bootstrap/lib/compiler/ebin/beam_ssa_dead.beam     |   Bin 12128 -> 11876 bytes
 bootstrap/lib/compiler/ebin/beam_ssa_lint.beam     |   Bin 7512 -> 7536 bytes
 etc...

那么我该怎么做呢?

提醒一下, git pull命令实际上是git fetch然后与给定(或已解决)的远程跟踪分支合并。

第一部分对您有用,是git pull的“提取”部分的输出。 第二部分是不需要的 ,它是随后的快进合并的输出。

您可以拆分操作,以便仅使第二部分静音:

git fetch
git pull -q

想要少打字吗? 做一个别名

git config --global alias.qpull '!git fetch && git pull -q'

然后做

git qpull origin <someBranch>  # for "quiet pull" for example but anything goes of course

RomainValeri所述git pull只是git fetch加上第二个Git命令。 这是第二个对您“嘈杂”的Git命令; git fetch打印您想要的内容。

git merge嘈杂的原因是因为git merge在默认情况下会先运行git diff --stat之后将HEADHEAD@{1}的先前值与当前值进行比较,然后(在这种情况下)打印Fast-forward ,并对分支名称执行快进操作,而不是合并,然后对更新的提交进行git checkout

git merge命令除了其他许多选项外,还采用以下三个选项:

--stat
-n
--no-stat
在合并结束时显示diffstat。 diffstat也由配置选项merge.stat
使用-n或--no-stat在合并结束时不显示diffstat。

因此,您可以将pull拆分为单独的组件(如RomainValeri所建议的),然后使用git merge -n :在这里您仍然会获得快进消息,而不是diffstat。

git pull命令通常会将其大多数选项发送给git merge 包括-n--no-stat 它的一些选项会继续发送到git fetch ,而一些选项会同时发送给这两个选项。 最后是在此处使用-q的问题:它同时涉及基础提取后续合并。 如果要使用-q ,这将迫使您将命令分为两个部分。

您也可以将merge.stat配置为false ,而不必进行任何处理。 之后,所有合并将变得更加安静。

出于多种原因,我通常建议无论如何git pull拆分git pull 最重要的一点是,通常在git fetch ,我想检查一下我获取的内容,以决定是否该合并,重新设置基准,或者不进行合并。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM