Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 693
Franck Freiburger Avatar asked Oct 14 '22 22:10

Franck Freiburger


People also ask

Why is GitHub rejecting my push?

A commit gets rejected and causes a failed to push some refs to error because the remote branch contains code that you do not have locally. What this means is that your local git repository is not compatible with the remote origin.

How do I turn off email privacy on GitHub?

Head to the Settings section of GitHub, and then select the Emails menu item. In here, you'll find a checkbox labeled 'Keep my email addresses private'. Within the description for this label, you'll find your GitHub noreply address.

What does it mean to push to GitHub?

The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.


2 Answers

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.

  5. 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
    
like image 726
Daniel A.A. Pelsmaeker Avatar answered Oct 17 '22 11:10

Daniel A.A. Pelsmaeker


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.

like image 157
Jordan Lewis Avatar answered Oct 17 '22 12:10

Jordan Lewis