Change the date of a git commit

Rewriting git history by changing the commit date.
created by on 2013-01-16

If you want to change the commit date of a specific commit you can use the filter-branch command:

git filter-branch -f --env-filter \
'if [ $GIT_COMMIT = <commit-hash> ]
 then
     export GIT_AUTHOR_DATE="<New-Commit-Date>"
     export GIT_COMMITTER_DATE="<New-Commit-Date>"
 fi'

Example:

git filter-branch -f --env-filter \
'if [ $GIT_COMMIT = 6b29de964c1d66b0a5e40de2272ce864bccca139 ]
 then
     export GIT_AUTHOR_DATE="Mon Jan 13 22:07:15 2014 +0100"
     export GIT_COMMITTER_DATE="Mon Jan 13 22:07:15 2014 +0100"
 fi'
Tags:
Fork allmark on GitHub