Backdating Git Commits

Changing Dates for the Most Recent Commit

You can backdate the author date and commit date of your last commit and then push it. To change the author date:

git commit --amend --no-edit --date="Sun Mar 21 13:53:21 2021 -0500"

To change the commit date:

$GIT_COMMITTER_DATE="Sun Mar 21 13:53:21 2021 -0500" git commit --amend --no-edit

See both dates of the commits:

git log --pretty=fuller


git push

If you have the commit pushed to remote, you will need to force push the backdated local commit to overwrite the remote one.

git push -f origin main

Changing Dates on Multiple Commits in the History

To pick the commits you want to edit among the last 5 commits:

git rebase -i HEAD~5

This will open your text editor. Replace the word pick with reword for the commits for which you want to edit the commit message, or replace it with edit to amend it (we will use this to change dates). Repeat the steps above for editing author date or commit dates and use the following to proceed to edit the next commit each time.

git rebase --continue

Alternatively, you can use the following to stop after each commit starting from the one listed and editing as needed.

git rebase --interactive '8aca69e^'