5

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?

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Robert
  • 39,162
  • 17
  • 99
  • 152
  • 3
    *[...] my commits/pushes still contain my account and computer name [...]* Where, in your commits, do you see that information? Try running `git log --raw -1`. Do you see the info in question in the output of this command? – jub0bs Dec 18 '14 at 15:50
  • 1
    Even after explicitly setting the email it uses an auto-generated email in the form username@pc-name (pc-name includes the name and the FQDN. – Robert Dec 18 '14 at 16:20
  • See https://stackoverflow.com/a/56232509/52817 – laktak May 21 '19 at 06:49

2 Answers2

8

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 <jubobs@jubobs-MacBook-Pro.local>
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

Community
  • 1
  • 1
jub0bs
  • 60,866
  • 25
  • 183
  • 186
1

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 username@users.noreply.github.com 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 ID+username@users.noreply.github.com. 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 username@users.noreply.github.com. 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.

Robert
  • 39,162
  • 17
  • 99
  • 152