Output of git command is not fully redirected to a file

后端 未结 1 1357
忘掉有多难
忘掉有多难 2021-01-15 13:25

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

manish@rigved:~$ git fetch --all --prune >          


        
相关标签:
1条回答
  • 2021-01-15 13:54

    You need to redirect stderr in addition of stdout.

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

    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:

    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.

    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.

    0 讨论(0)
提交回复
热议问题