Error "Your push would publish a private email address"
I experienced the same error: GH007
message as well and used the following to resolve the issue.
- Go to Setting your commit email address.
- Follow the Setting your email address for every repository on your computer.
- Open your GitHub account, and go to Settings → Emails.
- Select the Keep my email address private check box.
- Unselect the Block command line pushes that expose my email check box.
This may expose your email address though.
When enabling the “Block command line pushes that expose my email” feature, you’ll also want to configure Git to use your no-reply email address. Don’t worry—this won’t affect your contribution graph. All commits will still be associated with your account.
Open Terminal.
Change the current working directory to the local repository where you want to configure the email address that you associate with your Git commits.
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.
Set an email address in Git. Use your GitHub-provided no-reply email address.
Setting your email address for every repository on your computer
git config --global user.email "{ID}+{username}@users.noreply.github.com"
Setting your email address for a single repository
git config user.email "{ID}+{username}@users.noreply.github.com"
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.
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
Once you configure Git, commits will use your alternate “noreply” email address, and any pushes that don’t will be rejected.
Open Emails section of github.com. Visit https://github.com/settings/emails.
Go to
Keep my email addresses private
section and note down yourdonotreply
email id.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"
- Revert your recent local commits (with your private email) which are getting failed to be pushed into repository.
git reset --soft HEAD~1
- Stage and push those commits
git add .
git commit –m "<commit_message>"
git push