git命令的输出没有完全重定向到文件

git命令的输出没有完全重定向到文件

问题描述:

git fetch 命令的输出从下面的cmd重定向到 test1 文件:

The output of git fetch command, is redirected to "test1" file from the below cmd:

manish@rigved:~$ git fetch --all --prune > test1
From https://github.com/Beawel/wwwnew
 x [deleted]         (none)     -> origin/test

问题:然而 x [删除] ... 输出中显示的行不会重定向到test1,为什么?请建议。

Question: However the "x [deleted] ..." line as shown in the output is not redirected to test1, why? Please suggest.

为什么一个git命令会在stderr上打印出明显的不是错误消息?

Why a git command would print what is clearly not an error message on stderr?

manish@rigved:~$ cat test1
Fetching origin


您需要重定向标准输出以及标准输出。

You need to redirect stderr in addition of stdout.

git fetch --all --prune > test1 2>&1

更重要的是,为什么在stderr而不是stdout上发布信息?

特定于git(和 not 是记录良好的stderr重定向的副本)。

More importantly, why a git command does emit information on stderr instead of stdout?
That is specific to git (and not a duplicate of the well-documented stderr redirection).

正如我在这里解释的

As I explained here:


它与Git中的其他进度报告一致。

将stdout的输出重新输入到stderr,因为它只是提供信息的消息,不会被机器消耗。

It is consistent with the rest of progress reporting within Git.
Reroute the output of stdout to stderr as it is just informative messages, not to be consumed by machines.

您可以在stdout git命令输出中找到可能被链接管道序列中的其他命令使用的输出。

任何其他消息(不打算被其他命令使用)将被重定向到stderr。

You would find on stdout git command outputs that could potentially by used by other commands in a chained-pipe sequence.
Any other message (not meant to be consumed by other commands) is redirected to stderr.