简体   繁体   English

git log和git show的不同漂亮格式?

[英]Different pretty formats for git log and git show?

I have this in my .gitconfig : 我在.gitconfig有这个:

[format]
    pretty = %C(yellow)%h%Cred%d%Creset - %C(cyan)%an %Creset: %s %Cgreen(%cr)

This makes the output of git log look like this (plus some nice colors): 这使得git log的输出看起来像这样(加上一些漂亮的颜色):

6b1d043 (origin/master) - Ismail Badawi : Don't redirect to index after saving query. (28 hours ago)
df98a3e - Ismail Badawi : Store example queries in database & cache results (30 hours ago)
6de44ab - Ismail Badawi : Add sanity check tests for different pages. (31 hours ago)
7b6b46b - Ismail Badawi : Save query results for saved queries. (31 hours ago)

I find this format easy to scan through. 我发现这种格式很容易扫描。 I don't like that it also affects git show though; 我不喜欢它也会影响git show ; in particular, I'd like to be able to see the full commit message in the output of git show , not just the title line; 特别是,我希望能够在git show的输出中看到完整的提交消息,而不仅仅是标题行; also the actual date instead of relative, the author email, etc. 还有实际的日期而不是相对的,作者的电子邮件等。

Is there some way to use different default formats for git log and git show ? 有没有办法为git loggit show使用不同的默认格式?

Both git log and show use the same configuration. git logshow使用相同的配置。

--format=<format>
    Pretty-print the contents
    ...
    Note: you can specify the default pretty format in the repository configuration (see git-config(1)).

https://www.kernel.org/pub/software/scm/git/docs/git-show.html https://www.kernel.org/pub/software/scm/git/docs/git-show.html

However, why don't you just define an alias to one of them and use that instead? 但是,为什么不直接为其中一个定义别名并使用它? For example, you could have git alias.vshow 'show --pretty=<your other format string>' . 例如,您可以使用git alias.vshow 'show --pretty=<your other format string>'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM