Last Updated: February 25, 2016
·
15.74K
· raviolicode

Change the date of a commit in Git

It's generally never a good idea to do it, but I found one case it was useful.

A commit has two dates: the author date, and the commit date.

To rebase to the commit:
1. git rebase -i <hash of the commit to change>
2. select to edit only that commit

To change only the commit date:

git commit --amend --date "`date -R`"

To change both author and commit dates:

GIT_COMMITTER_DATE="`date-R`" git ci --amend --date "`date -R`"

End the rebase with git commit --continue.