Skip to content

Instantly share code, notes, and snippets.

@lexisother
Last active August 1, 2023 18:15
Show Gist options
  • Save lexisother/05346cf87602cc0ccdb3e80f4e428c20 to your computer and use it in GitHub Desktop.
Save lexisother/05346cf87602cc0ccdb3e80f4e428c20 to your computer and use it in GitHub Desktop.
Reset commit metadata after rebasing

WARNING: ONLY DO THIS IN PERSONAL REPOSITORIES!!!

What I know now is that you can just use the --committer-date-is-author-date with a range of all dirty commits after a rebase session that reset a lot of dates.

The above seems to not always work. When in doubt:

git -c rebase.instructionFormat='%s%nexec GIT_COMMITTER_DATE="%cD" git commit --amend --no-edit --allow-empty --allow-empty-message' rebase -i HEAD~N

Old solution

Kludged together from this SO post.

After a rebasing session, this can be used to re-set the dates to their original value and re-sign the commits.

git filter-branch --env-filter 'GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; export GIT_COMMITTER_DATE'
git rebase -i --root -x "git commit --amend -S --no-edit &&  git rebase --continue"
git rebase --committer-date-is-author-date -i --root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment