简体   繁体   中英

Different pretty formats for git log and git show?

I have this in my .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):

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; 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; 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 ?

Both git log and show use the same configuration.

--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

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>' .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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