Meaning of the GitHub message: push declined due to email privacy restrictions

GitGithubGit PushPrivacy Policy

Git Problem Overview


I have accepted and merged a pull request on GitHub, and now I cannot pull my commits any more.

The message is:

! [remote rejected] master -> master (push declined due to email privacy restrictions)
error: failed to push some refs to '[email protected]:FranckFreiburger/vue-resize-sensor.git'


git did not exit cleanly (exit code 1) (3838 ms @ 12/04/2017 21:23:11)

What should I do now?

Git Solutions


Solution 1 - Git

The remote repository has been configured to disallow you pushing a commit that would reveal your personal e-mail address. For example in GitHub you have checked the Block command line pushes that expose my email checkbox to enable this.

Block command line pushes that expose my email

While you can of course uncheck that setting, it will expose your private e-mail address to everyone in the world, as author information is readable by anyone with access to your repository.

Instead, do this:

  1. You can see your personal e-mail address, which is used by default for your commits in Git:

    git config --global user.email
    
  2. Find your GitHub noreply address in your GitHub's Personal Settings → Emails. It's mentioned in the description of the Keep my email address private checkbox. Usually, it starts with a unique identifier, plus your username:

    {ID}+{username}@users.noreply.github.com
    

    Keep my email address private

  3. Change the global user e-mail address setting to be your GitHub noreply address:

    git config --global user.email {ID}+{username}@users.noreply.github.com
    
  4. Reset the author information on your last commit:

    git commit --amend --reset-author
    

If you have multiple commits with your private e-mail address, see this answer.

  1. Now you can push the commit with the noreply e-mail address, and future commits will have the noreply e-mail address as well.

    git push
    

Solution 2 - Git

This is likely caused by a new GitHub setting that blocks command line pushes that expose your email address.

Try unchecking the "Block command line pushes that expose my email" box in your email settings and then pushing again.

Solution 3 - Git

  1. Open Emails section of github.com. Visit https://github.com/settings/emails.
  2. Go to Keep my email addresses private section and note down your donotreply email id.
  3. Open git terminal and set your donotreply email id as your email id using following command:
git config --global user.email "<your_donotreply_email_id"
  1. Revert your recent local commits (with your private email) which are getting failed to be pushed into repository.
git reset --soft HEAD~1 
  1. Stage and push those commits
git add .
git commit –m "<commit_message>"
git push

Solution 4 - Git

There is 3 options you can use:

1. You could uncheck your Keep my email addresses private in your GitHub E-mail Settings.

2. If you want hide e-mail your repositories, GitHub provide a noreply e-mail address in GitHub e-mail settings

> Because you have email privacy enabled, will be used for account-related notifications as well as password resets.

> [email protected] will be used for web-based Git operations, e.g., edits and merges.

git config --global user.email "<your-noreply-github-email>"

3- Or you can use your public email or business email for your repositories. Like m****@business.com

git config --global user.email "<your-public-email>"

After apply to your setting I recommend run reset header code :

git reset --soft HEAD~1 

Try again to push your repository

Solution 5 - Git

I solved the errors by:

git config --global user.email ""

This just sets my email to blank (an empty string). I now set my email in individual projects with:

git config user.email "[email protected]"

Solution 6 - Git

  1. Just go to github.com and click on your profile
  2. Go to settings
  3. Now click on the 'Email' on the left navigation panel
  4. And search for the field 'Keep my email addresses private'
  5. Please uncheck this option
  6. Now please check again and I think your problem is solved now.

Solution 7 - Git

Using Github Desktop fixed my issue.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFranck FreiburgerView Question on Stackoverflow
Solution 1 - GitDaniel A.A. PelsmaekerView Answer on Stackoverflow
Solution 2 - GitJordan LewisView Answer on Stackoverflow
Solution 3 - GitYuvraj PatilView Answer on Stackoverflow
Solution 4 - GitmaslancanView Answer on Stackoverflow
Solution 5 - GitNdirangu WaweruView Answer on Stackoverflow
Solution 6 - GitAnjani BarnwalView Answer on Stackoverflow
Solution 7 - GitNouman ChView Answer on Stackoverflow