質問

I frequently type git log when what I actually want is git log --decorate. How do I make it decorate by default?

I have seen lots of answers of the form "make an alias lg and then type git lg instead of git log". But, I can't find anywhere how to change the default behaviour of git log itself. alias log does not work.

役に立ちましたか?

解決

git config log.decorate auto

For a global setting, add the --global parameter.

So it would be:

git config --global log.decorate auto

The aliases are made with git config alias.lg "log --decorate"

他のヒント

Update April 2017, 3 years later:

With Git 2.13 (Q2 2017), no need for configuration: --decorate is the default!

See commit 940a911 (24 Mar 2017) by Alex Henrie (alexhenrie).
(Merged by Junio C Hamano -- gitster -- in commit d9758cf, 11 Apr 2017)

The default behaviour of "git log" in an interactive session has been changed to enable "--decorate".

That means you would need to override that option on command line, to get back to the old behavior (for just one log execution):

git -c log.decorate=false log

Original answer (mid 2014)

Note: since git 2.1.0-rc0 (July 2014), Linus Torvalds himself introduced a decorate=auto option.
That is more precise than just decorate=true, especially for scripting purpose, as explained below.

See commit 1571586 by Linus Torvalds (torvalds):

This works kind of like "--color=auto" - add decorations for interactive use, but do not change defaults when scripting or when piping the output to anything but a terminal.

You can use either

[log]
     decorate=auto

in the git config files, or the "--decorate=auto" command line option to choose this behavior.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top