Git
GitHub
email privacy
version control
error message

Error Your push would publish a private email address

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

This GitHub error means the commits you are trying to push contain an author email address that GitHub considers private based on your account privacy settings. The push is blocked to stop that private address from being exposed in commit metadata on the remote repository.

Why GitHub Blocks the Push

Every Git commit stores author and committer identity information, including an email address. If your local Git configuration uses a personal address and GitHub account settings are configured to keep that address private, GitHub can reject the push with the message about publishing a private email address.

The important point is that the problem is not your network push command. The problem is already embedded in the commit objects you are trying to send.

You can inspect the email in your latest commit like this:

bash
git log -1 --pretty=format:'%an <%ae>'

You can also inspect your configured email:

bash
git config user.email
git config --global user.email

Those commands tell you whether the unwanted address is coming from the commit itself, from local repo config, or from your global Git settings.

The Usual Fix: Use Your GitHub No-Reply Address

GitHub provides a no-reply address specifically for commits. Configure your repository or global Git identity to use that address instead of your private one.

For one repository:

bash
git config user.email "[email protected]"

Globally:

bash
git config --global user.email "[email protected]"

Use repository-local configuration if you want different identities for different projects. That is often safer than changing the global setting if you work across personal and corporate repositories.

Once your Git config is correct, new commits will use the new address. Old commits do not change automatically.

Rewrite Commits That Already Contain the Private Address

If the blocked push contains a fresh unpushed commit, the simplest repair is:

bash
git config user.email "[email protected]"
git commit --amend --reset-author --no-edit

That recreates the last commit with the current Git author settings.

If several recent commits contain the wrong address, you need to rewrite that part of history before pushing. For example, an interactive rebase can be used for a short unpublished branch:

bash
git rebase -i HEAD~3

Mark the relevant commits for edit, amend them after setting the correct email, then continue the rebase.

The key rule is simple: GitHub is rejecting the push because the commits already contain the private address. Changing config alone helps future commits, but it does not repair the existing ones.

Decide Whether You Want Privacy or Exposure

There are really two valid resolutions:

  • keep email privacy enabled and rewrite commits to use a no-reply address
  • intentionally allow your real email to be published and adjust GitHub privacy settings

For most people, the first option is the safer default. It gives you a stable public commit identity without exposing a personal mailbox.

If you do choose the second option, make that decision consciously. Commit metadata is durable and easy to inspect later.

Common Pitfalls

The biggest mistake is changing git config user.email and then retrying the push without rewriting the already-created commits. The push still fails because the commit metadata did not change.

Another issue is fixing the email globally when the real problem is only one repository. Local repository configuration is often a better fit when you use different identities for different work.

Developers also sometimes check only git config user.email and forget that the rejected commit may already have been authored with a different address earlier. Inspect the commit log directly.

Finally, do not rewrite published shared history casually. If the bad commits are already on a shared remote, rewriting them affects other collaborators and needs coordination.

Summary

  • GitHub blocks the push because the commits contain an email address your privacy settings treat as private.
  • Check both your Git configuration and the actual commit metadata.
  • The usual fix is to use your GitHub no-reply email address.
  • Existing commits must be amended or rebased to replace the private email before pushing.
  • Changing config only affects future commits, not the commits that already exist.

Course illustration
Course illustration

All Rights Reserved.