After reinstalling the system a few days ago, I accidentally committed a lot of commits with author "root"<root@localhost> and looked for a way to modify them.

Create a new shell script called fix.sh in the repository root directory and type the following.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  #!/bin/bash git filter-branch --env-filter ' an="$GIT_AUTHOR_NAME" am="$GIT_AUTHOR_EMAIL" cn="$GIT_COMMITTER_NAME" cm="$GIT_COMMITTER_EMAIL" if [ "$GIT_COMMITTER_EMAIL" = "Wrong email" ] then cn="Correct name" cm="Correct email" fi if [ "$GIT_AUTHOR_EMAIL" = "Wrong email" ] then an="Correct name" am="Correct email" fi export GIT_AUTHOR_NAME="$an" export GIT_AUTHOR_EMAIL="$am" export GIT_COMMITTER_NAME="$cn" export GIT_COMMITTER_EMAIL="$cm" ' 

When finished, run . /fix.sh and you’re done.