Reputation: 60054
I want to fix the email in the 10 most recent git commits (while keeping the timestamp when they were originally committed, like git rebase
does).
Alas, I cannot use --reset-author
because it also resets the timestamp.
I suppose I can use git format-patch
, then use sed
to fix the email, and then git am
to apply them.
Is there an easier way?
Upvotes: 0
Views: 186
Reputation: 312420
Well, it turns out I just had to do something similar. It looked a bit like this:
git rebase HEAD~4 -x 'GIT_AUTHOR_DATE="$(git show --format=%ad -s)" GIT_COMMITTER_DATE="$(git show --format=%cd -s)" git commit --amend -CHEAD --author "Bob <[email protected]>"'
This resets the author to "Bob [email protected]" on the most recent 4 commits, preserving both the committer and author dates.
Upvotes: 1
Reputation: 10750
Git filter-repo is probably the best tool for this! Construct a mailmap like so:
Old Name <[email protected]> Correct Name <[email protected]>
Save this in a file called mailmap.txt or something (it can be named anything).
Then, run git filter-repo in a fresh clone:
git filter-repo --mailmap path/to/mailmap.txt
Upvotes: 0