为什么`git show`不提供有关重定向标准输出的分支的信息? [英] Why `git show` doesn't provide info about branches for redirected stdout?

查看:75
本文介绍了为什么`git show`不提供有关重定向标准输出的分支的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是两个带有结果示例的命令:

Here are two commands with result examples:

$ 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,标签:v7.32,origin/master,origin/HEAD)" .

The important difference: in the second result no information about branches - "(HEAD -> master, tag: v7.32, origin/master, origin/HEAD)".

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

I also tried redirections of stdout and stderr to each other, redirect to file, grep, some other constructions. The same result, in the console showing everything, in other cases - no branches info.

为什么呢?

以及如何强制git返回整个消息?

And how to compel git to return the whole message?

推荐答案

如上述评论中的 @ElpieKay 所述,我需要在命令中使用键--decorate.

As said @ElpieKay in the comment above, I need to use the key --decorate with the command.

Git手册:

-decorate [= short | full | auto | no]

--decorate[=short|full|auto|no]

打印出所显示的任何提交的引用名称.如果指定了short,则不会打印ref名称的前缀refs/heads/,refs/tags/和refs/remotes/.如果指定了full,则将打印完整的引用名称(包括前缀).如果指定了auto,那么如果输出将输出到终端,则引用名称显示为好像给出了short,否则不显示引用名称.默认选项为 short .

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,如手册​​中所述.

But I'm pretty sure that by default uses auto instead short as it said in manual.

此问题已解决.

这篇关于为什么`git show`不提供有关重定向标准输出的分支的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆