Commit timestamps in GitHub don't match repo

I have various old git repos, including one or two converted from older repo managers (e.g. Perforce). They include commit comments from many years ago—some of the commits are older than a couple of the people I work with! But now that these projects are in GitHub, the commit dates are completely wrong. If I type git log for a file at the command line, and the most recent commit date is from several years ago, the same commit in GitHub has a much more recent timestamp.

The way I went about it was to create a new (private) repo in GitHub, type git remote add origin, and git push -u origin master. Nothing fancy.

Does GitHub just not like old dates, or is there data somewhere in my git repos that might not necessarily match what’s in the git log? I know I’ve used git commit --date for some commits, which look correct in git log, but not in GitHub. Are there any tricks to get the dates in GitHub to match what’s in the git log? Because the git log dates are correct, as far as I’m concerned, and they’re the ones I want to see in GitHub.


1 Like

Hey hey @mscheper! I guess I’m curious what you do see in GitHub? Do you see dates for these commits as the time they were committed? Or an even less accurate, irrelevant date?

If it’s displaying the date it was committed, and not the historic commit date you see in commit log, you’ll want to make sure the author date, matches the historic value.

I want to elevate our relevant docs, but also, this ol SO post.

Between these two, you should have what you need, but the remote add might not be updating both author and commit dates from your history.

If there is anything more GitHub-specific that isn’t answered in those threads, follow up and I’ll do what I can!


I didn’t realise there was a distinction between the ‘author date’ and ‘commit date’. It does seem odd that GitHub would choose to show a different date from what’s in the logs, but I’m sure some thought went into that decision, and I know a lot of people are more comfortable with history being rewritten than I. :slightly_smiling_face:

I fixed it with these commands:

git filter-branch --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
git push -f

GitHub doesn’t seem bothered by dates older than it is, either. :wink:

Thanks for your help!

1 Like

Not a problem at all! I’m glad I could be helpful :bow: