Git
Commit in the Past

How to commit in the past?

There are two dates for a commit:

  • author date
  • commit date

Setting --date in commit command will set only author date. To change both, GIT_AUTHOR_DATE and GIT_COMMITTER_DATE environment variables can be set:

DESIRED_DATE=$(date -d "-1 day")
GIT_AUTHOR_DATE=$DESIRED_DATE GIT_COMMITTER_DATE=$DESIRED_DATE git commit -m "Your message"