Search code examples
gitdategit-log

How to make `git log` show only the commit date, nothing else


I just want to get a quick glance at the history of a project by having git log show only the commit date, nothing else. How can we best do that?


Update:

It turns out I was actually asking for the author date, which is what is shown by git log. To see the committer date too, which can be different, run git log --pretty=fuller.

See also here: Why is git AuthorDate different from CommitDate?

To help make this point that there are different dates: to set an author date when running git commit, use:

git commit ---date "<date>"

To set also the committer date, you'd have to do:

GIT_COMMITTER_DATE="<date>" git commit --date "<date>"

See here: How can one change the timestamp of an old commit in Git?


Solution

  • If you want to see only the committer date (the date the commit was written with it's current ID):

    git log --format=%cd
    

    If you want to see only the author date (the date the commit was originally written, but may differ from the committer date if the commit was amended, rebased, cherry-picked, etc, which caused it to get a new commit ID):

    git log --format=%ad
    

    More info on the difference between committer and author dates: Why git AuthorDate is different from CommitDate?.

    Dates can be displayed in different ways. Here's a list of built-in options.

    Also, if you don't want to use a pager, just add --no-pager after the git command, like this:

    git --no-pager log --format=%ad