Installation
You'll need to first install the dependency on filter-repo.
If you're on a Mac, you can do that with:
brew install filter-repo
Usage
Then you can use the --email-callback option (see docs), which takes a string that will be evaluated into python, to provide the desired replacement:
git filter-repo --email-callback 'return email.replace(b"old_email@example.com", b"new_email@example.com")'
Double-check locally to see if everything went as expected. For example, the command below should return no occurrences of the old email:
git log | grep old_email@example.com
With that, you can finally push force to the main branch on your remote repo:
git push origin "$(git_current_branch)" --force
Known issues
Notice that filter-repo might have removed your remote reference in the process. You can fix that by manually setting your remote URL with:
git remote add origin git@github.com:username/reponame.git
ย