Rawan 2018
Rawan 2018

Reputation: 321

What's the difference between git log and git log --decorate?

I have test the two commands and I didn't see any difference between the output of them.

git log output with and without --decorate

The below question from front-end developer course

Using what you know about an order git log, do you see the tag in the log output? the correct answer is No, git log --decorate not git log

What's the difference between them?

Upvotes: 18

Views: 7509

Answers (2)

VonC
VonC

Reputation: 1325357

With Git 2.33 (Q3 2021), the documentation is clearer regarding git log --decorate default value:

See commit a0538e5 (08 Jun 2021) by Đoàn Trần Công Danh (sgn).
(Merged by Junio C Hamano -- gitster -- in commit 5ae1eb2, 08 Jul 2021)

doc/log: correct default for --decorate

Reported-by: Andy AO
Signed-off-by: Đoàn Trần Công Danh

There're two different default options for log --decorate: * Should --decorate be given without any arguments, it's default to short * Should neither --decorate nor --no-decorate be given, it's default to the log.decorate or auto.

We documented the former, but not the latter.

Let's document them, too.

git log now includes in its man page:

The option --decorate is short-hand for --decorate=short.

Default to configuration value of log.decorate if configured,
otherwise, auto.

Upvotes: 3

larsks
larsks

Reputation: 311750

There seems to be a change in behavior depending on what version of git you're using.

Older versions of git (say, 1.8.x) default to not decorating the output of git log. More recent versions of git (since 2.12.2) default to --decorate=auto (which is just like --decorate=short when output is to a terminal, but acts like --no-decorate otherwise).

In other words, with version 1.8.3. running git log I see:

commit 0b57f44b3371521f65eb7607310803c7e90dc023

But with 2.14.4 I see:

commit 0b57f44b3371521f65eb7607310803c7e90dc023 (HEAD -> master, origin/master)

I can get the same output with the older version of git using git log --decorate.

In other words, if you're running a modern version of git, there will be no difference in the output of git log and git log --decorate.

Upvotes: 31

Related Questions