Modify git commit timestamp

Sometimes it’s useful to modify the timestamp of a git commit, like when archiving old files (I usually want the timestamp to match when the file was last modified, rather than todays date)

This can be done easily once the files have been committed, but before they are pushed

git commit --amend --date "Apr 19 19:12:01 2010"
GIT_COMMITTER_DATE="Apr 19 19:12:01 2010" git commit --amend

You can now see the updated timestamps in your git history, and can push you’re file to Github with a more appropriate timestamp.

Leave a Reply

Your email address will not be published. Required fields are marked *