Github Desktop with private commit email from Github

Hi Guys,
I have set my email address private within Github and afterwards I wanted to commit changes in an existing repository using GIthub Desktop which didn’t work due to my email settings I had set in the Github settings page. Therefore I have changed the email address in Github Desktop (Settings > Git: Email) to the given no-reply Github email given from the settings page of the Github Website, which again led to the error “Cannot push these commits as they contain an email address marked as private on GitHub.” when pushing or creating a new repo. How do I solve the problem and enter my no-reply email address?

Thanks in advance :+1:.

@M00nD3v this is likely because you previously made commits with a private email address. Updating your email address in GitHub Desktop did not change the email address for commits that you already made.

There are a few options to resolve this:

  1. Uncheck the “Keep my email private” checkbox and push your commits. Your private email will be used for any future commits.
  2. Use the “Undo” button in GitHub Desktop if it is available. If you only made one commit you may be able to use this option to fix your initial commit.
  3. Reset your local changes and commit them again. You will need to use the git reset command from the command line to do this, since GitHub Desktop does not have this functionality built in. Select the commit you would want to “reset” back to and right-click > Copy SHA. Then switch to your command line and run git reset <SHA> – this will move you back to that commit and leave you with uncommitted changes that can then be committed using the correct email address.

I hope that helps!

1 Like

If you’re willing to use the command line, there are two more options:

  1. Use git rebase -i: Mark all commits with the wrong mail address as edit, and at each step use git commit --amend --author="Your Name <your.mail@example.com>" (or simply git commit --amend --reset-author, if you don’t mind resetting the commit time, too).
  2. If there are a lot of commits it may be worth using git filter branch as described here: Changing author info