user997112
user997112

Reputation: 30605

git log, show the dates in a usable format?

Somebody has already formulated this alias for our git log:

git log --graph --abbrev-commit \
    --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'

However, this shows 5 days ago rather than 02/12/2018 16:47:00

I tried adding --date=local but it didn't make any difference.

How can I change the above to show the datetime?

Upvotes: 0

Views: 49

Answers (1)

Makoto
Makoto

Reputation: 106389

The formats manual suggests that you use %cd in place of %cr to get a timestamp respected by the --date format, which you can then set independently of this invocation.

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit

The above produces a timestamp in the form of Wed Oct 17 15:51:57 2018 -0600 for me.

Upvotes: 3

Related Questions