Rewriting the Git Author
I decided to switch my (yet-to-be-released) personal infrastructure repository to use my shivjm.in email address. I thought it would be easy with git rebase --root -x "git commit --amend --no-edit", but that changes the commit date (distinct from the author date):
Each git commit is identified by a hash that is computed using the commit's properties: content, message, author and committer date and email.
A rebase always changes the committer date. It can also change committer email, commit message and content too.
Fortunately, Git provides a --committer-date-is-author-date flag. Unfortunately, the following command neither updated the author nor preserved the date:
git rebase --root -x "git commit --amend --no-edit" --committer-date-is-author-date
This one changed the author but also the commit date (enjoy the ridiculous PowerShell quoting requirements):
git rebase -x "git commit --amend --no-edit --author=`"`"`"New Author <email@example.com>`"`"`"" --root --committer-date-is-author-date
And finally, this is what I had to do to both change the author and preserve the original date:
git rebase -x "git commit --amend --no-edit --author=`"`"`"New Author <firstname.lastname@example.org>`"`"`"" --root --committer-date-is-author-date && git rebase --root --committer-date-is-author-date
In other words, one (slow) rebase to rewrite the author, another (quick) rebase to restore the date.