Ferhat's rabbit hole

How to control date in a git commit properly

Published on
Published on
/1 mins read

Setting --date in commit command will set only author date.

To change both commit and author date, GIT_AUTHOR_DATE and GIT_COMMITTER_DATE environment variables can be used as follows:

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