Changing the timestamp of a previous Git commit
Git has two different types of timestamp associated with a commit. Although both may typically hold the same value they are used in subtly different ways. The author (GIT_AUTHOR_DATE) is the user who originally created the work (i.e. a patch), where as the committer (GIT_COMMITTER_DATE) is the user who last applied the work (i.e. applied patch or rebase). The author date is the one displayed when the log is accessed, however, the commit date is used when given the filter (–since, –until) options, which seems a little odd. To avoid confusion you can include the committer date within your log display by setting the –format option.
A tendency I have picked up is to be very commit happy when developing locally, and then find myself rebasing a lot before pushing to a remote. As a result of this I sometimes am required to alter timestamps of certain commits to make them more meaningful. I found that the simplest of which is adding a specified timestamp to the current commit. The author date is specified with the –date option where as the committer timestamp has to be changed with an environment variable.
If on the other hand we wish to amend the last author commit you can execute the following, very similar command. I should warn you to be wary of running these next commands on a branch with commits that you have already pushed to a remote - due to Git’s hashing nature this will alter the SHA’s of all commits that come after the desired commit as well.
Finally, to alter a previous commit by SHA reference hash, you can run the following command (altered from GitFaq).
Viewing the alterations
We can now check out our handy work by looking at the log again, providing –since and –until options to filter the results.