为什么“git show”不提供重定向标准输出的分支信息?

2024-09-29 17:22:54 发布

您现在位置:Python中文网/ 问答频道 /正文

以下是两个命令及其结果示例:

$ git show

commit 6f367e05cc6457fd0c0fc59fe0476db06cffb383 (HEAD -> master, tag: v7.32, origin/master, origin/HEAD)
Merge: 94ecf1d8 f3ea52b0
Author: Pupkin <pupkin@server.com>
Date:   Fri Dec 13 12:49:12 2019 +0700

    Some commit description.

$ echo `git show`

commit 6f367e05cc6457fd0c0fc59fe0476db06cffb383 Merge: 94ecf1d8 f3ea52b0 Author: Pupkin <pupkin@server.com> Date: Fri Dec 13 12:49:12 2019 +0700 Some commit description.

重要的区别是:在第二个结果中,没有关于分支的信息-“(HEAD->;master,tag:v7.32,origin/master,origin/HEAD)”

我还尝试了将stdout和stderr重定向到彼此,重定向到文件,grep,以及其他一些构造。同样的结果,在控制台中显示所有内容,在其他情况下-没有分支信息

为什么会这样

如何强迫git返回整个消息


Tags: gitmastercomdateservertagshoworigin
1条回答
网友
1楼 · 发布于 2024-09-29 17:22:54

正如上面评论中所说的@ElpieKay,我需要在命令中使用键 decorate

Git manual开始:

decorate[=short|full|auto|no]

Print out the ref names of any commits that are shown. If short is specified, the ref name prefixes refs/heads/, refs/tags/ and refs/remotes/ will not be printed. If full is specified, the full ref name (including prefix) will be printed. If auto is specified, then if the output is going to a terminal, the ref names are shown as if short were given, otherwise no ref names are shown. The default option is short.

但我非常确定,在默认情况下使用auto而不是short,正如手册中所说的那样

这个问题解决了

相关问题 更多 >

    热门问题