Change email address on git history

Photo by Yancy Min on Unsplash

Change email address on git history


1 min read


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


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"", b"")'

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

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