Git Hack: Make commit with a past date

Subscribe to my newsletter and never miss my upcoming articles

Ever wanted to commit something to a git repo with a past date? Here’s how you could do it.

If you are working on a project and missed a commit yesterday or you accomplished the task but GitHub for Windows bailed on you? Well, this little hack can solve your problem.

Pre-Step. Pull all data from remote to local repository.

For the same, we are using the --amend and --date switches. The exact command is as follows:

$ git commit --amend --date="YYYY-MM-DD HH:MM:SS"

Simple, isn't it!

This should solve your problem. If you have any Queries or Suggestions, please reach out to me in the Comments Section below.

Have fun!

Repository for Ultimate Resource in python. Drop a star if you find it useful! Got anything to add? Open a PR on the same! Also, have a look at my other Blogs:

If you have any Queries or Suggestions, please reach out to me in the Comments Section below.

Lee Hansel Solevilla's photo

Good stuff.

Though be wary of amending commits (message) when working with other developers. It rewrites the commit which would result as different on those who already pulled it.

Show +1 replies
Lee Hansel Solevilla's photo

Saifur Rahman Mohsin notice when i mentioned "when working with other developers".

Saifur Rahman Mohsin's photo

Lee Hansel Solevilla Yeah, I did. Absolutely agree with your point.

Mark's photo

Interesting, thanks!

Git has a committer and author date, do you happen to know which one(s) this updates?