Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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?

like image 639
Rawan 2018 Avatar asked Jun 24 '18 12:06

Rawan 2018


1 Answers

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.

like image 50
larsks Avatar answered Sep 29 '22 19:09

larsks