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

问题描述 投票:1回答:2
  • 所以我在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 github git-pull
2个回答
5
投票

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

对你有用的第一部分是git pull的“fetch”部分的输出。第二部分,你不想要的,是随后的快进合并的输出。

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

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

1
投票

作为RomainValeri notesgit pull只是git fetch加上第二个Git命令。这是第二个给你“吵闹”的Git命令; git fetch打印出你想要的东西。

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

The git merge command在其他许多选择中占据了这三个:

--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 fetch之后,我想检查我所得到的是什么时候进行合并,变革,或者两者都没有。

© www.soinside.com 2019 - 2024. All rights reserved.