Git: Name und E-Mail Adresse zu Commits in Git-Historie ersetzen

Achtung: git filter-branch ändert die Historie. Siehe dazu diesen Hinweis aus der git-filter-branch(1) Manpage:

WARNING! The rewritten history will have different object names for all the objects and will not converge with the original branch. You will not be able to easily push and distribute the rewritten branch on top of the original branch. Please do not use this command if you do not know the full implications, and avoid using it anyway, if a simple single commit would suffice to fix your problem.

Skript zum Ersetzen von Name und E-Mail Adresse

FROM_COMMITTER_NAME='BISHERIGER NAME'
TO_NAME='NEUER NAME'
TO_EMAIL='neue_email@example.com'
        
git filter-branch --commit-filter "
        if [ \"\$GIT_COMMITTER_NAME\" = '${FROM_COMMITTER_NAME}' ]; then
                GIT_COMMITTER_NAME='${TO_NAME}';
                GIT_AUTHOR_NAME='${TO_NAME}';
                GIT_COMMITTER_EMAIL='${TO_EMAIL}';
                GIT_AUTHOR_EMAIL='${TO_EMAIL}';
                git commit-tree \$@;
        else
                git commit-tree \$@;
        fi" HEAD