As developers, we sometimes want to change past Git commits. Although true time travel is impossible, Git offers a neat way to commit with past dates and times. Here's how:
To change the last commit date and time, use this command:
git commit --amend --date="YYYY-MM-DD HH:MM:SS" -m "Your commit message here"
To create a new commit with the past date, use:
git commit --date="YYYY-MM-DD HH:MM:SS" -m "Your commit message here"
Conclusion:
Keep in mind that amending a commit means rewiring its history. Use this powerful feature responsibly.