Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot push these commits as they contain an email address marked as private on GitHub

Tags:

github

push

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

like image 439
Yeadh Avatar asked Sep 13 '18 18:09

Yeadh


People also ask

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.

How do I enable email privacy on GitHub?

If you'd like to keep your personal email address private, you can use a noreply email address from GitHub as your commit email address. To use your noreply email address for commits you push from the command line, use that email address when you set your commit email address in Git.

How do I add a commit email to GitHub?

Setting your commit email address on GitHub In the upper-right corner of any page, click your profile photo, then click Settings. In the left sidebar, click Emails. In the "Primary email address" list, select the email address you'd like to associate with your web-based Git operations.

What email should I use for Git?

Git CLI setup: You could use any email address. But, you must have used an email address that is connected with your GitHub account. The email address linked with Github ensures that commits are attributed to you and appear in your contributions graph.


5 Answers

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.

like image 191
raider33 Avatar answered Oct 06 '22 22:10

raider33


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.

like image 32
jotaelesalinas Avatar answered Oct 06 '22 21:10

jotaelesalinas


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

like image 30
aazimkhani Avatar answered Oct 06 '22 22:10

aazimkhani


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.

like image 45
Eli Avatar answered Oct 06 '22 23:10

Eli


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.

like image 30
Arash Dadkhah Avatar answered Oct 06 '22 23:10

Arash Dadkhah