All posts

Masking Email Addresses in Git History with Rebase and Filter-Rewrite

Git logs preserve author and committer information by design. During a rebase, those values carry forward unless explicitly changed. If you need to mask, rewrite, or anonymize email addresses in Git history, rebase is one of the fastest tools to do it—when you know the right flags and filters. Start by running an interactive rebase on the commits you want to alter: git rebase -i HEAD~N Replace N with the number of commits to process. Mark each commit as edit. Then, for each stop in the reba

Free White Paper

Data Masking (Dynamic / In-Transit) + Git Commit Signing (GPG, SSH): The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

Git logs preserve author and committer information by design. During a rebase, those values carry forward unless explicitly changed. If you need to mask, rewrite, or anonymize email addresses in Git history, rebase is one of the fastest tools to do it—when you know the right flags and filters.

Start by running an interactive rebase on the commits you want to alter:

git rebase -i HEAD~N

Replace N with the number of commits to process. Mark each commit as edit.

Then, for each stop in the rebase, use:

git commit --amend --author="Name <masked@example.com>"
git rebase --continue

This rewrites the author metadata. To mask committer emails as well, set the GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL environment variables before amending.

For large histories, use git filter-repo (or git filter-branch if you must) to batch-rewrite all author and committer emails:

Continue reading? Get the full guide.

Data Masking (Dynamic / In-Transit) + Git Commit Signing (GPG, SSH): Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.
git filter-repo --mailmap my-mailmap

A .mailmap file lets you map real emails to masked addresses without touching every commit manually. Example:

Real Name <real@example.com> Masked Name <masked@example.com>

After rewriting, force-push to all relevant branches:

git push --force --all

Be aware: this changes commit hashes and requires all collaborators to re-clone or reset.

Masking email addresses in Git logs protects privacy and helps meet security or compliance goals. Done right, a rebase or history rewrite updates past commits without breaking the repository structure. Done wrong, it leaves leaks in place or corrupts history.

Test on a clone, keep backups, and confirm with:

git log --pretty=format:"%an <%ae>"| sort -u

Your logs should now show only masked emails.

Try it yourself in a live environment. Spin up a secure Git workspace at hoop.dev and see proper email masking in minutes.

Get started

See hoop.dev in action

One gateway for every database, container, and AI agent. Deploy in minutes.

Get a demoMore posts