Rewrite author info in commit messages with git-filter-repo

git-filter-repo is a tool to rewrite GitHub repository commit history. It can be used to rewrite authors information on a commit.

mailmap

To use git filter-repo, you’ll need to prepare a mailmap file, which is used to replace your old author names and emails with the new ones. The syntax for the mailmap file is as follows:

Correct Name <correct@email.com> OLD NAME1 <old@email1.com>
Correct Name <correct@email.com> OLD NAME2 <old@email2.com>

Feel free to add as many OLD NAME and OLD EMAIL entries as necessary for multiple author names that need to be changed.

Jii Yoo <yjii@pm.me> John Doe <john@doe.com>
Jii Yoo <yjii@pm.me> John Doe <johndoe@example.com>
Jii Yoo <yjii@pm.me> Jane Doe <jane-doe@example.com>

git-filter-repo

Please note that you need a freshly cloned repository. If you are performing this on an existing repository, it’s advisable to re-clone it.

cd repo

# /repo
git filter-repo --mailmap your-mailmap

After completing the task, the origin remote will be automatically removed. To restore it, you will need to add the origin back to your repository using the following command:

repo/$ git remote add origin REPO-URL

And force push.