Disclaimer: This guide was done using Windows. The installation steps and commands may vary for other operating systems.
Author and committer email and name can be updated in the Git history using git-filter-repo
.
Note: You will need Python 3 and the
git-filter-repo
tool to run the commands. Below is how I added it on Windows:
-
Install Python 3:
- Download and install Python 3 from the official site: python.org.
- During installation, make sure to check the box to add Python to your system PATH.
-
Install
git-filter-repo
:- Open your terminal (e.g., PowerShell or Command Prompt) and run the following command to install
git-filter-repo
via pip:pip install git-filter-repo
- Open your terminal (e.g., PowerShell or Command Prompt) and run the following command to install
-
Verify Installation:
- To verify that the installation was successful, run the following command inside a Git repository:
python -m git_filter_repo --analyze
- To verify that the installation was successful, run the following command inside a Git repository:
The following command will replace all instances of an old email with a new one in both the author and committer fields of every commit in the history.
python -m git_filter_repo --commit-callback "
if commit.author_email == b'old_email':
commit.author_email = b'your_github_no_reply_email@users.noreply.github.com'
if commit.committer_email == b'old_email':
commit.committer_email = b'your_github_no_reply_email@users.noreply.github.com'
"
The following command will replace all instances of an old name with a new one for both the author and committer names.
python -m git_filter_repo --commit-callback "
if commit.author_name == b'Old Name':
commit.author_name = b'New Name'
if commit.committer_name == b'Old Name':
commit.committer_name = b'New Name'
"
- Make sure to replace
old_email
,your_github_no_reply_email@users.noreply.github.com
,Old Name
, andNew Name
with your actual values. - After running these commands, you may need to push the rewritten history to your remote repository using
git push --force
.