Back to scan
Fix Your Commit Email Privacy
Follow these three steps to stop exposing your personal email in Git commits and optionally rewrite your existing history.
- Go to GitHub Settings → Emails
- Check "Keep my email addresses private"
- Check "Block command line pushes that expose my email"
Set your noreply email as the default for all future commits:
For all repositories (global)
git config --global user.email "ID+USERNAME@users.noreply.github.com"For a single repository
git config user.email "ID+USERNAME@users.noreply.github.com"Verify the change
git config --global user.emailAll future commits will now use your noreply email. Existing commits are notaffected — see Step 3 to fix those.
Warning: destructive operation
Rewriting history changes commit SHAs and requires a force push. This will break open pull requests, invalidate references, and affect all collaborators. Only do this if you understand the consequences. Back up your repository first.
Method A: git filter-repo (recommended)
git-filter-repo is the modern, faster replacement for git filter-branch.
Install
pip install git-filter-repoRun
git filter-repo --email-callback '
return email.replace(b"your-real-email@example.com",
b"ID+USERNAME@users.noreply.github.com")
'Method B: git filter-branch (legacy)
Older method, still works but slower on large repos.
git filter-branch --env-filter '
OLD_EMAIL="your-real-email@example.com"
NEW_EMAIL="ID+USERNAME@users.noreply.github.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]; then
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]; then
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tagsForce push the changes
After rewriting, you must force push to update the remote:
git push --force --tags origin 'refs/heads/*'Coordinate with your team before force pushing. All collaborators will need to re-clone or rebase their local copies.
You're taking the right step
Once you've completed these steps, all new commits will use your noreply email, and GitHub will block any accidental pushes that expose your real address.