Git commits have two dates associated with them: the author date and the commit date. The author date stores the original time when the commit was made, and the commit date stores the last modified time. Though these two dates usually match, they become different whenever commits are rebased onto another branch or are applied via a patch to another repository. In these cases, the author date remains unchanged while the commit date is updated, allowing the original commit author to retain credit for their work while enabling the committer to also receive credit for applying the change.

This can sometimes be confusing when using everyday git operations. For example, git log displays author dates but git log --since "1 day ago" (or the complementary --until) filters on commit date. In fact, most git operations work off of the commit date.

What if you're looking for a certain commit, but you can only remember when it was originally authored instead of when it was applied? To be honest, I can't think of a real reason that someone would need to do this, but I was curious enough to investigate anyway. Turns out, it's a difficult problem that can't be done purely with git.

I guess the next best thing is modifying author dates or commit dates to keep them in sync. I don't recommend it, but the various methods for manipulating dates are presented below in case you ever need them.

To set author dates:

git commit --date="Fri Jul 23 12:00 2021 +0000"

To set commit dates, use the environment variable instead:

GIT_COMMITTER_DATE="Fri Jul 23 12:00 2021 +0000" git commit

Note: GIT_AUTHOR_DATE also exists, but the --date flag is easier for me to remember.

To keep commit date and author date in sync:

git commit --amend --committer-date-is-author-date