Make a Git commit for the past date and time #
Format #
GIT_AUTHOR_DATE="YYYY-MM-DD HH:MM:SS" GIT_COMMITTER_DATE="YYYY-MM-DD HH:MM:SS" git commit -m "commit message"
Usage #
Replace YYYY-MM-DD HH:MM:SS
with the desired date and time.
For example:
GIT_AUTHOR_DATE='2024-02-01 at 09:30' GIT_COMMITTER_DATE='2024-02-01 at 09:30' git commit -m "Add content"
Be cautious: Do not modify commits that you’ve already pushed to remote repository shared with others as rewrite history can lead to issues. If you really need to, always coordinate with your team and understand the implications when rewriting Git history.