Does Git publicly expose my e-mail address?

Viewed 41085

The guides I've read so far on Git say that I should go into the config and specify my name and my e-mail address. They don't elaborate; they just say to do it.

Why does Git need my e-mail address? And, more importantly, if I make my repo publicly available, via GitHub for example, will my e-mail address be visible to everyone (including spambots)?

9 Answers

Git uses your email address to identify you, as well as do other tasks (such as sign a tag with a GPG key). Your email address does get embedded as part of your identity in commit logs, etc., along with the name you specify. For example, the "author" field in a commit log would show up as:

Author: Joe White <joewhite@mysite.com>

So the information is available to anyone with a copy of the repo, since it acts as an identifier.

Your email probably won't be visible to spambots, though, unless you use Gitweb, or a service like GitHub, to make your repo available through a web interface (merely putting it on the Internet doesn't do this).

I suppose you could fill in a fake email address or use an empty string or space or something (I don't think Git checks the format or validity of the email), but the email is useful if someone who clones the repo needs to send you a patch or contact you in some way.

Yes, the above answers are correct ... except you want to typically have the same email address for all your projects then you would use the command:

git config --global user.email "me@email.com"

You can also edit the .gitconfig file in your home directory, in the user section.

You can specify a different email for a particular project by doing the same command without the global option.

Also, I suggest that you can obfuscate your email if the submits are going to a public area:

briancolfer(at)comcast.net

As an example.

Yes, your email address (as specified in git config user.email) will be visible in web interfaces like GitWeb. Also everybody can learn your email address by cloning your repository though this is probably still far beyond spambots. Nobody forces you to use a real email address, though. Git will automatically set a constructed email address if none is given. On my machine without user.email it shows commits by “Foo <foo@daughter.(none)>”.

if I make my repo publicly available, via GitHub for example, will my e-mail address be visible to everyone

Note: you can also make your repository locally available, through a local gitweb (web frontend to Git repositories, packaged with a regular Git distribution, and which can be installed with git instaweb).

And with Git 2.32 (Q2 2021), "gitweb" learned "e-mail privacy" feature to redact strings that look like e-mail addresses on various pages.

See commit 0996dd3 (28 Mar 2021) by Georgios Kontaxis (kontaxis).
(Merged by Junio C Hamano -- gitster -- in commit a9414b8, 13 Apr 2021)

gitweb: add "e-mail privacy" feature to redact e-mail addresses

Signed-off-by: Georgios Kontaxis
Acked-by: Eric Wong
Acked-by: Ævar Arnfjörð Bjarmason

Gitweb extracts content from the Git log and makes it accessible over HTTP.
As a result, e-mail addresses found in commits are exposed to web crawlers and they may not respect robots.txt.
This can result in unsolicited messages.

Introduce an 'email-privacy' feature which redacts e-mail addresses from the generated HTML content.
Specifically, obscure addresses retrieved from the the author/committer and comment sections of the Git log.
The feature is off by default.

This feature does not prevent someone from downloading the unredacted commit log, e.g., by cloning the repository, and extracting information from it.
It aims to hinder the low- effort, bulk collection of e-mail addresses by web crawlers.

gitweb.conf now includes in its man page:

email-privacy

Redact e-mail addresses from the generated HTML, etc. content. This obscures e-mail addresses retrieved from the author/committer and comment sections of the Git log.
It is meant to hinder web crawlers that harvest and abuse addresses. Such crawlers may not respect robots.txt.
Note that users and user tools also see the addresses as redacted. If Gitweb is not the final step in a workflow then subsequent steps may misbehave because of the redacted information they receive.
Disabled by default.

Related