Bhaskar
Bhaskar

Reputation: 2723

`git log` output not the same as input date format

Here is my git log command:

git log --no-merges --date=format:'%Y-%m-%d' --format=format:'%C(bold blue)%h%C(reset) %C(green)%cD%C(reset) %C(cyan)%an%C(reset) %sd'

Here is the output:

b4d6b7b8c Wed, 24 Aug 2022 19:31:20 -0700 FirstName1 LastName1 Sample subject 1
14d2b9170 Wed, 24 Aug 2022 19:23:12 -0700 FirstName2 LastName2 Sample subject 2
8c4fda8b2 Wed, 24 Aug 2022 18:53:54 -0700 FirstName3 LastName3 Sample subject 3
...

I was expecting dates to be in 2022-08-24 format in the output.

I read the Git documentation, particularly the --date options. What mistake am I doing? Does it have to do with committer date (%cD) cannot be changed to the format I requested?

Upvotes: 2

Views: 23

Answers (1)

ElpieKay
ElpieKay

Reputation: 30858

Use the placeholder %cd instead of %cD.

%cd

committer date (format respects --date= option)

%cD

committer date, RFC2822 style

Reference: https://www.git-scm.com/docs/git-log#Documentation/git-log.txt-emcdem

Upvotes: 5

Related Questions