Git commit date / time / author edit

If the Git commits have already been pushed to remote, this process will require other users of the repo to reset, rebase or reclone, as for any Git operation that edits history. If the Git commits have not already been pushed, then this process will not require extra steps from other repo users.

Show Git commit AuthorDate and CommitDate by

git show <commit_hash> --pretty=fuller

for the most recent commit, simply:

git show --pretty=fuller

edit last commit only

To reset the author of the last commit to the current Git username and email, as well as setting AuthorDate and CommitDate to the current time:

git commit --amend --reset-author --no-edit
--reset-author
reset date/time/author to current
--no-edit
skip opening text editor

edit previous commits, including already pushed

Use git rebase -i as usual and for the commits to reset author / date, change the operation to e to edit each by:

git commit --amend --reset-author --no-edit

Specific date setting

Specific commit times can be set with a combination of the “–date” option and environment variable GIT_COMMITTER_DATE.

Reference

GitHub commit troubleshooting