Skip to content

Instantly share code, notes, and snippets.

@ardislu
Created November 26, 2024 08:33
Show Gist options
  • Save ardislu/ddd570114ac4b8d92f3bf536fa660cc6 to your computer and use it in GitHub Desktop.
Save ardislu/ddd570114ac4b8d92f3bf536fa660cc6 to your computer and use it in GitHub Desktop.

How to change your last git commit's CommitDate and AuthorDate

  1. Show the last git commit and confirm it's the one you want to edit:
$ git log -n 1 --pretty=fuller
commit 0000000000000000000000000000000000000000 (HEAD -> main)
Author:     First Last <[email protected]>
AuthorDate: Tue Nov 26 01:01:01 2024 -0800
Commit:     First Last <[email protected]>
CommitDate: Tue Nov 26 01:01:01 2024 -0800

    Example description
  1. Edit the AuthorDate:
$ git commit --amend --date="Mon Nov 25 02:02:02 2024 -0800" --no-edit
  1. Edit the CommitDate to match the AuthorDate:
$ git rebase --committer-date-is-author-date
  1. Confirm the dates have changed:
$ git log -n 1 --pretty=fuller
commit 0000000000000000000000000000000000000000 (HEAD -> main)
Author:     First Last <[email protected]>
AuthorDate: Mon Nov 25 02:02:02 2024 -0800
Commit:     First Last <[email protected]>
CommitDate: Mon Nov 25 02:02:02 2024 -0800

    Example description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment