Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 11

push declined due to email privacy restrictions

Solved! Go to Solution.

Although I've set my `git --global user.email` to the `no-reply` email adress which I fund in my github email preferences, I still get this error:

 

$ git push origin readme-dev

Counting objects: 8, done.         
Delta compression using up to 4 threads.                               
Compressing objects: 100% (8/8), done.                                 
Writing objects: 100% (8/8), 984 bytes | 984.00 KiB/s, done.           
Total 8 (delta 6), reused 0 (delta 0)                                  
remote: Resolving deltas: 100% (6/6), completed with 5 local objects.
remote: error: GH007: Your push would publish a private email address. [...] ! [remote rejected] readme-dev -> readme-dev (push declined due to email privacy restrictions)

 

10 Replies
Community Manager
Message 2 of 11

Re: push declined due to email privacy restrictions

Hi @Troyciv,

 

If you run git config --local --list does it display a different email than you have in your global Git config?

 

Thanks!

Copilot Lvl 3
Message 3 of 11

Re: push declined due to email privacy restrictions

It didn't show any email. I also tried to add a local email which than showed up in the `git config --local --list`. Still got the same error.

However, when I try to push my local master branch to the remote master branch it seems to work, only my newly created local development branch will not push with `git push origin dev`

Moderator
Message 4 of 11

Re: push declined due to email privacy restrictions

Can you show the output of the command `git config --show-origin --get-regexp "user.*"`?

Copilot Lvl 3
Message 5 of 11

Re: push declined due to email privacy restrictions

file:/home/user/.gitconfig      user.name Troyciv                   
file:/home/user/.gitconfig      user.email 14926781+Troyciv@users.noreply.github.com
file:.git/config        user.email 14926781+Troyciv@users.noreply.github.com
Moderator
Message 6 of 11

Re: push declined due to email privacy restrictions

@Troyciv it looks like everything is configured correctly now but it is possible that you have some commits on that other branch that were written with some other values. You should be able to use the command `git log --first-parent --no-merges` when on the other branch to take a look at the commit information to find which commits have non-private email information. Then you can use `git rebase -i` to rewrite those commits so they have the new private email information.

Highlighted
Solution
Ground Controller Lvl 1
Message 7 of 11

Re: push declined due to email privacy restrictions

I just encounterd the same problem.

 

The steps I took to fix (thanks for the advice on this thread) were roughly as follows:

git config --global user.email "526473+gb96@users.noreply.github.com"
git rebase -i
git commit --amend --reset-author
git rebase --continue
git push

 

I found rebase -i allowed be to edit the commit message but retained the previous (private) email address in the log.

The commit --amend --reset-author seemed to be the easiest way to replace the offending email address.

Copilot Lvl 3
Message 8 of 11

Re: push declined due to email privacy restrictions

That solved it, thank you

Ground Controller Lvl 1
Message 9 of 11

Re: push declined due to email privacy restrictions

I'm not at all sure what happened, but this ended up costing me a day's work. I followed the directions exactly, and ended up losing a commit that hadn't yet been pushed.

Ground Controller Lvl 1
Message 10 of 11

Re: push declined due to email privacy restrictions

Just need to remove one checkbox as described here:

 

https://stackoverflow.com/questions/43378060/meaning-of-the-github-message-push-declined-due-to-emai...

 

This is likely caused by a new GitHub setting that blocks command line pushes that expose your email address.

Try unchecking the "Block command line pushes that expose my email" box in your email settingsand then pushing again.