13

When I am trying to push my commits with GitHub Desktop it showing this error "Cannot push these commits as they contain an email address marked as private on GitHub"

Please help me how to fix this error

3

7 Answers 7

12

The other answers are fine for future commits, but don't help for prior commits that contain a public email address. If you want to keep your email private, then you should modify the prior commits instead of changing your settings. Use git cmd, like:

git commit --amend --author="ericraider33 <[email protected]>"

And fill in with auto-generated email address that GitHub provides to each user.

1
  • 1
    This is useful. But you are missing the leading "<" before the email address, i.e. it should be <[email protected]>
    – arcdale
    Mar 23, 2020 at 8:02
9

Go to settings -> emails and disable "Keep my email address private".

1
  • 1
    This is what fixed the error for me. BTW, This is done on github.com/settings/emails : github.com > Click your profile picture > settings > Emails > "Keep my email addresses private "
    – AllisonC
    May 9, 2020 at 18:47
7

If you still don't want to expose your email address:

  1. Go to https://github.com/settings/emails and save your "noreply address".

  2. Set your git email address to this noreply address, either with the command git config --global user.email "[email protected]" or inside GitHub Desktop's preferences.

  3. Save somewhere the changes that you want to push.

  4. Revert changes in your last commits, as they were signed with the previously configured email address.

  5. Restore the changes that you saved.

  6. Commit.

  7. Push.

6

I ran into this problem too. It is an easy fix in Github Desktop by going to File -> Options -> Git and clear the Username and Email fields and save it. Then if you are logged in to GitHub it will fill them in with correct information.

0
1

You're likely pushing a commit that is signed using your email address, and in your settings on Github. You can change this behavior by either going to GitHub (browser) clicking on the user icon on the top right corner -> Settings -> Emails and unchecking the box that says "Block command line pushes that expose my email", make your email not private (right above that option), or sign your commits with a public email.

0

If you are using GitHub Desktop there is the possibility to reverting the commit (go to "History" tab and right click on the commit to revert). Then, change your email to your private email, and commit again. And then you can push.

0

@raider33 solution works but if you need to do it for all previous commits, then it is described in GitHub's "Amending older or multiple commit messages" section

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.