How to fix GitHub 007 error

Pushing commits to Github with the private email address

Ravic Poon
2 min readAug 15, 2022

The problem

I came across the “Keep my email addresses private” feature on GitHub the other day. Out of curiosity, I decided to turn it on without thinking about the side effects.

In the realm of software engineering, change comes with consequences, regardless of how small it is. In my opinion, this is a prime example of it.

I was greeted by an error message from git after a push command:

remote: error: GH007: Your push would publish a private email address.
remote: You can make your email public or disable this protection by visiting:
remote: http://github.com/settings/emails
To github.com:superspy/secretmission.git
! [remote rejected] logs/mission -> logs/mission (push declined due to email privacy restrictions)

The solution

First, head over to https://github.com/settings/emails and copy the proxy email address (underlined in red) generated by Github.

Github email settings page
Github email settings page

Next, change your git user email config to the proxy one using this command:

git config --global user.email \
"916316+superspy@users.noreply.github.com"

p.s: “916316” is the ID and “superspy” is the NAME of your GitHub account. You can also remove the --global config to scope the change to the current git repo.

Finally, you have to reset the author of your commit without editing the commit:

git commit --amend --reset-author --no-edit

Voila! You can push your commit to the remote branch using the private email address feature.

commit 71a47d8ced7f32a72289f649508b77a453df4130
Author: superspy <916316+superspy@users.noreply.github.com>
Date: Wed Nov 16 12:34:50 2047 -0700
mission accomplished

--

--