Email address visible on GitHub and how to stop it

While trying out the Github API, I noticed that my email is displayed in the public events, even though I clearly marked it as private in the settings. However, this is not due to Github.

Wie ist dies passiert?

The cause is quickly found. Before you can create a push, git requires a username and an email address. Nice enough, there is also a command for this in the git logs:

just run the following commands:

git config --global user.name "FIRST_NAME LAST_NAME"
git config --global user.email "MY_NAME@example.com"

Without thinking about it, I simply entered my email without thinking about it. Until I stumbled across the fact that this is publicly visible via the API, despite the settings.

How can I check myself?

To test this you can simply go to the following link:
https://api.github.com/users/{your_username}/events/public

Here you can see recent events of the last 90 days and if you have stored your email in the configs, you probably will find it here.

Another place is about a commit. Simply go to commit of your and append a `.patch` at the end of the URL to see your e-mail.

here you can find a detailed explanation: https://www.nymeria.io/blog/how-to-manually-find-email-addresses-for-github-users

How can I fix this?

First, we have to change the git configs so that the email is no longer included.

We first need a new email address. You don't have to use a valid email address. It is up to you. I'm going to use the private address GitHub provides. You can read more about this here.

In short, just run the following command again with your new email:
git config --global user.email "new_address@example.com"

As an example, with the GitHub provided address:
git config --global user.email "48969167+EduardSchwarzkopf@users.noreply.github.com"

You can find your private email address in the GitHub email settings under the Keep my email addresses private checkbox

Removing the email from GitHub

I'm going to use the tool from Adam DeHaven called change git author

Disclaimer, from the repository

This action is destructive to your repository's history. If you're collaborating on a repository with others, it's considered bad practice to rewrite published history.

You should only do this in an emergency.

Running this script rewrites history for all repository collaborators. After completing these steps, any person with forks or clones must fetch the rewritten history and rebase any local changes into the rewritten history.

Just use this according to the manual, you'll be guided through it and can change your E-Mail and Name.

You'll need to do this for every single repository you've contributed in the past! So you might not be able to remove your email entirely.

Something I want to note, while I was going through this:
You need to provide a new name as well, it can be the same as before, but you need to provide something.

Subscribe to Eduard Schwarzkopf

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe