0

Git is failing to push a change for one file. Working remotely at a command prompt, I did the following (abbreviated steps):

  • clone our team's main repo
  • git checkout chuck (this is my existing branch)
  • started editing a file
  • git add file_name (maybe I didn't need this because it's existing)
  • git commit -m "some comment"

But now when I want to push the change, I get

remote: error: GH007: Your push would publish a private email address. remote: You can make your email public or disable this protection by visiting: remote: http://github.com/settings/emails To https://github.com/my_company/our_repo/ ! [remote rejected] chuck -> chuck (push declined due to email privacy restrictions) 

I looked at the web Github email settings. They are set to private, which is why it happens. But I'm not clear how to get past it.

1

3 Answers 3

1

If you check on Github emails link you will find that it provides an email address like: [email protected] or [email protected] based on when you created the account. So use that email for the commits which should fix the issue.

From Github:

If you created your GitHub account after July 18, 2017, your GitHub-provided no-reply email address is a seven-digit ID number and your username in the form of [email protected]. If you created your GitHub account prior to July 18, 2017, your GitHub-provided no-reply email address is your username in the form of [email protected]. You can get an ID-based GitHub-provided no-reply email address by selecting (or deselecting and reselecting) Keep my email address private in your email settings.

To use the email address on your commit set that to git config using:

To set globally:

git config --global user.email "[email protected]" 

Or for a single repo:

git config user.email "[email protected]" 
Sign up to request clarification or add additional context in comments.

5 Comments

I did that but it didn't allow the push. In the email settings, I had to uncheck "Block command line pushes that expose my email"
after unchecking that, I could push. Thanks.
Could you check your git log once and see which email address it is using as "Block command line pushes that expose my email" setting only works for personal emails. More details here: docs.github.com/en/github/…
from "git log", the first entry has my company email (the one I want to keep private).
So that means your config setting didn't work or you created the commit and changed the config. As you unchecked the checkbox it would expose your company email in commits now.
0

I had to uncheck "Block command line pushes that expose my email"

Comments

0

My issue involved GitHub found a Personal Access Token secret in the attempted push. I had this in .env file. Github gave me the option to allow the 'secret' and successfully git push -u origin main

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.