Getting cannot push commits as they contain a private email address error

I’ve got some code that I want to put into a new repo on GitHub. I’ve already performed a git init to initialize the repo locally. I’m also using GitHub Desktop, so that I can push it to a new repo in my GitHub account. When I tried I got the:

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

error message. I do want to keep my email private, so I used the git config --local user.email command to defined the email address for this repo. (I use multiple Git hosts, so I try to define the email address for each local repo.

However, when I do a git config --list I see that both my private email is shown (defined globally, I presume) and the users.noreply.github.com also is displayed, which I presume if the local definition for this local repo.

What I’d like to know is how do I proceed so I can push this code into the remote repo on GitHub, yet only use the users.noreply.github.com email address?

You’ll need to check git log to see if there are already any commits with your private address. If so, you’ll need to rewrite the commit history to remove it. Unfortunately the Github documentation mentioned there seems to have disappeared recently, but the script should still work. :wink:

@airtower-luna, I’ve just run the git log. It reports that I’m on the master branch and there are no commits yet. How do you recommend I proceed?

Hm, that’s odd! If there are no commits there’s nothing to push yet.

I don’t know why Github Desktop would talk about mail addresses then, I hope someone with knowledge specific to Github Desktop can answer that! :sweat_smile:

That’s correct, I haven’t changed any of the files. I’m just trying to get the files I have locally into a new repo on GitHub.

I issued a git config --local --list command. It showed me the NoReply GitHub issued email address, which is exactly what I want it to be. Then I issued the git config --global --list and saw that it’s my personal email address. I would think that the local user.email address would supersede the global user.email address. So, I changed the global email address to be the GitHub issued NoReply. Then I verified the change had taken effect. It had. Then I tried to Publish the branch - it failed with the same error.

So, I hope someone more experience at GitHub Desktop can explain the problem, please.

I’m still puzzled by the error message, but if you want to push files you’ll have to commit them first.