Robert
Robert

Reputation: 42640

How can I prevent Git from using an email of the form username@pc-name instead of an empty one?

Whenever I try to use GIT it automatically enriches my commits with a lot of private data like user name, email and/or pc-name.

How do I configure GIT correctly so that it never automatically discloses my private data?

I already performed

git config --global user.name Robert
git config --global user.email ""

However my commits/pushes still contain my account and computer name which I consider to be private data.

What is necessary to make GIT not to publish my personal information into the repositories/internet?

Upvotes: 5

Views: 2406

Answers (2)

Robert
Robert

Reputation: 42640

In case the GIT repository belongs to a GitHub project specifying an invalid email address is not recommended. Instead GitHub specifies the following alternative (cite from GitHub help):

If you'd like to keep your email address private, set your Git config email to [email protected] instead, replacing username with your GitHub username.

Note: 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.

Upvotes: 1

jub0bs
jub0bs

Reputation: 66284

Running

git config --global user.email ""

clears the user.email field of your user-level config file, which will lead Git to assume that you haven't set your email address yet (under the assumption that no email address is specified in the repository-level config file, of course).

As a countermeasure, Git will generate an email address of the form username@pc-name (where pc-name includes the name and the FQDN) and will bake that email into your commits instead:

$ git log -1
commit 9cd00b7ed6206086bf332e0481092590d07626d5
Author: jubobs <[email protected]>
Date:   Thu Dec 18 16:23:19 2014 +0000

However, it is possible to trick Git into using an empty email address; you simply need to run the following command instead (tested with Git 2.1.3):

git config --global user.email "\<\>"

Then, Git won't use the autogenerated email address mentioned above:

$ git log -1
commit 0d0bb289b293ec020b607021bbd886be5107bc7f
Author: Jubobs <>
Date:   Thu Dec 18 16:25:14 2014 +0000

Related: Git commit with no email

Upvotes: 8

Related Questions