0

I'm a new Git/GitHub user developing on a Windows 10 machine and I've been having lots of trouble pushing my code to my remote repo. A lot of the trouble seems to stem from checking the "Keep my email addresses private" and "Block command line pushes that expose my email" checkboxes in GitHub.

Is there any way I can push my code when both boxes are checked? So far, the only way I've found to get a successful push to my public repo is by unchecking the "Block command line pushes that expose my email" checkbox and to establish my remote as follows:

git remote add origin https://[USERID]:[PASSWORD]@github.com/[USERID]/[Project].git

I also set my email to the surrogate value in my local repo via:

git config --global user.email [8-digit-code]+[USERID]@users.noreply.github.com

Isn't the whole idea of this surrogate ID to enable me to push THAT, which hides my real email from people watching my traffic or looking at my repo, while allowing GitHub to store something that it can map to my real email address for its own purposes?

Can someone enlighten me on how I can keep both checkboxes checked and still push successfully?

Henry
  • 1,395
  • 1
  • 12
  • 31
  • Did you accidentally set `git config user.email` (not global) as well? – matt Nov 29 '20 at 13:45
  • Or have you added commits with your own email prior to setting the hidden email? – jessehouwing Nov 29 '20 at 15:04
  • In that case you'll need to change all the commits up till now with the correct email. You can use `filter-branch`: https://stackoverflow.com/a/750182/736079 – jessehouwing Nov 29 '20 at 15:07
  • @matt - Thank you, you were correct; I had inadvertently set my local user.email to my real email address, then set the global one to the surrogate. Since the local always takes precedence over the surrogate, it makes sense that I would get error GH007. To remedy that, I set the git config user.email to the surrogate address, checked the "block pushes" checkbox and then pushed successfully. Would it have been any better to unset the local user.email or would that cause other problems? – Henry Nov 29 '20 at 15:17
  • @jessehouwing - Yes, I had done some commits with the correct email but since none of them pushed successfully, I decided to solve that problem with the brute force method: I dropped the remote repo, then recreated it with the same name. I figured that would let me start with a clean slate. – Henry Nov 29 '20 at 15:21
  • @jessehouwing - I know that dropping a remote repo and recreating it would be a horrible solution if I actually had code in there so I looked at the link you cited but quickly got confused about which of the many solutions in there were appropriate for my situation; most of them date back to 2009 and I have to assume things have changed to some extent since then. – Henry Nov 29 '20 at 15:23
  • Filter-branch is mostly unchanged. Basically you need to re-do ever commit with your real email and use the masked email instead. – jessehouwing Nov 29 '20 at 16:53

1 Answers1

1

The problem is that while you were fussing around you had already set git config user.email (not global) to your real email. Hence your change to your global email had no effect for this repository. You tried to push with your real email, and GitHub pushed back as you had told it to.

matt
  • 515,959
  • 87
  • 875
  • 1,141