Git Hack: Make commit with a past date
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.
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:
- Python 3.9: All You need to know
- The Ultimate Python Resource hub
- GitHub CLI 1.0: All you need to know
- Become a Better Programmer
- How to make your own Google Chrome Extension
- Create your own Audiobook from any pdf with Python
- You are Important & so is your Mental Health!
If you have any Queries or Suggestions, please reach out to me in the Comments Section below.
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.