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.

  1. Go to GitHub Settings → Emails
  2. Check "Keep my email addresses private"
  3. Check "Block command line pushes that expose my email"

Your noreply email address

GitHub provides you a private noreply email in the format:

ID+USERNAME@users.noreply.github.com

You can find your exact noreply address on the Emails settings page. For accounts created before July 18, 2017, the format may be USERNAME@users.noreply.github.com.

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.email

All future commits will now use your noreply email. Existing commits are notaffected — see Step 3 to fix those.

Method A: git filter-repo (recommended)

git-filter-repo is the modern, faster replacement for git filter-branch.

Install

pip install git-filter-repo

Run

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 --tags

Force push the changes

After rewriting, you must force push to update the remote:

git push --force --tags origin 'refs/heads/*'

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.