DEV Community

Alex
Alex

Posted on

Why Git Has Two Dates: Author Date vs Commit Date

Most developers assume a Git commit has a single timestamp.

That's not true.

Every commit actually contains two different dates:

  • Author Date
  • Commit Date

Most of the time they are identical, which is why many developers never notice the distinction.

But once you start rebasing, cherry-picking, or rewriting history, the difference becomes important.

Understanding these two timestamps can explain some very confusing Git and GitHub behavior.

Every Commit Contains More Metadata Than You Think

Let's inspect a commit:

git show --pretty=fuller HEAD
Enter fullscreen mode Exit fullscreen mode

Example output:

commit 7fd2f85...

Author: John Doe
AuthorDate: Mon Jul 1 10:00:00 2026 +0000

Commit: John Doe
CommitDate: Thu Jul 10 18:42:00 2026 +0000
Enter fullscreen mode Exit fullscreen mode

Notice that Git stores two separate timestamps.

Why?

Because they represent different events.

What Is Author Date?

The Author Date represents when the change was originally created.

Imagine this workflow:

July 1   Create commit
July 5   Open pull request
July 10  Rebase branch
Enter fullscreen mode Exit fullscreen mode

The code was written on July 1.

That's the Author Date.

It answers the question:

When was this work originally authored?

What Is Commit Date?

The Commit Date represents when the current commit object was created.

This is where many developers get surprised.

When Git rewrites history, it creates completely new commit objects.

For example:

git commit --amend
Enter fullscreen mode Exit fullscreen mode

or

git rebase -i
Enter fullscreen mode Exit fullscreen mode

Both operations generate new commits.

As a result, the Commit Date changes.

It answers the question:

When was this version of the commit created?

Why The Dates Become Different

Let's take a simple example.

You create a commit:

July 1
Enter fullscreen mode Exit fullscreen mode

A week later you perform an interactive rebase:

July 8
Enter fullscreen mode Exit fullscreen mode

Result:

AuthorDate = July 1
CommitDate = July 8
Enter fullscreen mode Exit fullscreen mode

Nothing is wrong.

Git is preserving the original creation time while also recording when the rewritten commit object appeared.

Why GitHub Sometimes Looks Wrong

Many developers first encounter this distinction on GitHub.

You've probably seen something like:

Commit created: July 1
Displayed on GitHub: July 8
Enter fullscreen mode Exit fullscreen mode

and wondered:

Why did GitHub change my commit date?

Usually GitHub isn't wrong.

It's simply displaying metadata that changed after a rebase, cherry-pick, or amend operation.

Understanding Author Date and Commit Date immediately explains this behavior.

Changing Commit Dates

Changing the latest commit date is relatively straightforward.

GIT_COMMITTER_DATE="$(date)" \
git commit --amend --no-edit --date "$(date)"
Enter fullscreen mode Exit fullscreen mode

Changing older commits is significantly more annoying.

You typically need:

git rebase -i
Enter fullscreen mode Exit fullscreen mode

followed by manual date editing and history rewriting.

This becomes painful when multiple commits are involved.

Why Commit Hashes Change

Another common surprise:

Changing only the timestamp changes the commit hash.

Many developers expect the hash to stay the same because the code didn't change.

But Git hashes the entire commit object, including metadata.

That means:

Same code
Same files
Same message
Different timestamp
Enter fullscreen mode Exit fullscreen mode

results in:

Different commit hash
Enter fullscreen mode Exit fullscreen mode

This is expected behavior.

When Would You Change Commit Dates?

There are legitimate reasons:

  • Fixing incorrect system clocks
  • Repository migrations
  • Cleaning imported history
  • Reconstructing chronological order
  • Educational demonstrations
  • Privacy reasons

In most cases you should avoid rewriting public history, but for personal branches and local repositories it can be useful.

Final Thoughts

Git stores two timestamps because they answer two different questions:

Author Date

When was this work originally created?

Commit Date

When was this commit object created?

Once you understand the distinction, many confusing Git and GitHub behaviors suddenly make sense.

While researching Git timestamps, I ended up building a small tool called GitEditDate that makes editing commit dates easier without manually wrestling with complex rebase commands.

Until then, I had no idea how much metadata was hiding inside a simple Git commit.

Top comments (0)