Commit with a Past Date and Time in Git

Pradumna Saraf - Jul 21 '23 - - Dev Community

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"
Enter fullscreen mode Exit fullscreen mode

To create a new commit with the past date, use:

git commit --date="YYYY-MM-DD HH:MM:SS" -m "Your commit message here"
Enter fullscreen mode Exit fullscreen mode

Conclusion:

Keep in mind that amending a commit means rewiring its history. Use this powerful feature responsibly.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player