How to amend several commits in Git to change author

Warning: now deprecated in favor of filter-repo.

Rebase/amend seems inefficient, when you have the power of filter-branch at your fingertips:

git filter-branch --env-filter 'if [ "$GIT_AUTHOR_EMAIL" = "incorrect@email" ]; then
     GIT_AUTHOR_EMAIL=correct@email;
     GIT_AUTHOR_NAME="Correct Name";
     GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL;
     GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; fi' -- --all

(split across lines for clarity, but not necessary)

Be sure to inspect the result when you’re done, to make sure that you didn’t change anything you didn’t mean to!

Leave a Comment