I try to set the committer date of the latest commit to its author date. Usually this works with
git rebase --committer-date-is-author-date HEAD~1
git rebase --committer-date-is-author-date --root
git rebase --root uses the interactive rebase code (because the non-interactive code cannot "replay" the root commit), and
--committer-date-is-author-date is actually a flag passed to
git am, which implements the simple non-interactive cases.
git rebase does, at a fundamental level, is copy some commits (with, usually, some sort of change made during the copying process), then point a branch name at the final such copied commit. If there is just one commit you want to change-while-copying, you can use
git commit --amend instead of
git rebase. If there is only one commit in the entire repository, there can only be one commit that you need to change-while-copying, so this case will apply.
--committer-date-is-author-date, you will need to use the
GIT_COMMITTER_DATE variable to set the commit time stamp to some arbitrary value. You can also use
--date to override the author name and/or time-stamp. Hence:
t='2017-09-01 12:34:56' GIT_COMMITTER_DATE="$t" git commit --amend --date="$t"
would set both time stamps to September 1st of 2017, at 12:34:56. (I used a shell variable
t here to avoid typing in the same time stamp twice.)
--no-edit if you don't want to edit the commit message. Remember that the new commit will use whatever is currently in the index! If you have changed the index since extracting the HEAD commit, you may want to copy the
HEAD commit to a temporary index first, and use that.)