Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

`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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading