push declined due to email privacy restrictions

I found the documentation page:
https://help.github.com/en/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address

1 Like

As the selected solution does not explain what happened and may not fit to everyone I’d like to contribute to this rather old topic.

What happened and why?

Github.com refused to accept your push to the repository.

The cause for the initial issue was a privacy setting in your github account.

[x] Block command line pushes that expose my email

Where can I find it?

Click on your Icon -> Settings -> Email

What does that checkbox do?

When this is checked Github will block any push attempt that contains an email address that is setup within your account and marked as private (not visible).

This should prevent an accidental push that reveals personal information that you do not want to share with everyone on earth.

What are my options?

Depending on your own preferences you can

a) remove/replace any email-address within the commit to be pushed - which is a privacy-aware attempt and reflects the selected solution. This is the way to go if you do NOT want that this email will be published.
Be aware: removing your mail-address will make it harder for others that read your code to contact you if you are contributing to a larger project. And when you change the settings later commits will cause the same error message and you will have to apply the same fix again…

b) change the setting of that specific email address in your profile to be public (so others will be able to see it - as they would digging in your commit history after you push the code with the email address in it)

This is less private but you can push without rebasing / editing your commit, etc. You do not have to remove or alter the auther configuration.

c) just uncheck that checkbox. In this case the email-address will be still set to private BUT you will give it away as part of the git history.

My preferred setting. It is a tiny bit better in terms of privacy than b) but offers other an easy way to contact you. You don’t have to mess up your settings, no need to change commits.

Be aware that b) and c) give away your mail address! It may be a good idea to use an address that is limited to exactly this usecase.

To sum it up: This is not a problem that is caused by using an unregistered/unknown email address, it is the exact opposite! You told github to take care of your privacy but tried to push private data.

So take a minute to select the configuration that fits best to your needs and you will have this problem solved.

I hope this givs a little bit more insight if someone encounters the same issue.

8 Likes

@gb96 should those commands be run from a PowerShell prompt that’s running As Administrator?

No, the git config --global modifies user-specific configuration settings and should always be run under the developer’s credentials.

If you wanted to modify defaults for all users of a system then yes you would need to run as a local Administrator, in which case you should be doing a git config --system instead.

I suppose Windows PowerShell should work fine with git, however I usually prefer to use the git bash shell on Windows for better cross-platform consistency (less quirks or surprises).

1 Like

@gb96 wrote:
No, the git config --global modifies user-specific configuration settings and should always be run under the developer’s credentials.

If you wanted to modify defaults for all users of a system then yes you would need to run as a local Administrator, in which case you should be doing a git config --system instead.

I suppose Windows PowerShell should work fine with git, however I usually prefer to use the git bash shell on Windows for better cross-platform consistency (less quirks or surprises).

Then if I issued that commands that you listed in your solution, it would affect all my interactions with any Git hosting, such as Azure DevOps Services, Bitbucket, etc. My configurations, with respect to all Git hosting companies, would be affected and the GitHub noreply email address would be assigned to all of them.

Correct?

thanks,

it solved my problem!

I simply love you for this… saved my life.

1 Like

Thx, worked perfectly!

This worked, thank you! I chose to keep the checkbox on for "** Block command line pushes that expose my email" , in case anyone else ran into this. So changing the user.email to github-generated masked email worked and resolved this error that i ran into "_ remote: error __ : GH007: Your push would publish a private email address**_."

This is because of the github settings.

Uncheck the “Block command line pushes that expose my email” under Settings>Emails.

https://stackoverflow.com/questions/43378060/meaning-of-the-github-message-push-declined-due-to-email-privacy-restrictions

This is probably a bad idea. Bypassing security to avoid actually fixing the issue should not be a solution unless it’s intended for a private email to be shown publically. As recommended above, setting the correct author and removing the private email is the solution. 

1 Like

That solved it!
Thank you!

im trying to have a lobby bot but emaul says no coming through

your tip help me a lot…thx

Thanks for the info. It worked

Thank you! This was my very first commit to this repo so I didn’t have anything to rebase, but I didn’t realize before that the commit already listed my private email as the author. Not sure why Sourcetree doesn’t have this feature is beyond me…

1 Like

Sorry for the delay… I think if you just wanted to configure a privacy-preserving author email for the current git repo, you could just omit the --global flag and that should do the trick.

1 Like