Git 会公开我的电子邮件地址吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/897586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does Git publicly expose my e-mail address?
提问by Joe White
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.
到目前为止,我在 Git 上阅读的指南说我应该进入配置并指定我的姓名和电子邮件地址。他们没有详细说明;他们只是说去做。
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)?
为什么 Git 需要我的电子邮件地址?而且,更重要的是,如果我公开我的存储库,例如通过 GitHub,我的电子邮件地址是否对所有人(包括垃圾邮件机器人)可见?
采纳答案by mipadi
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:
Git 使用您的电子邮件地址来识别您的身份,并执行其他任务(例如使用 GPG 密钥签署标签)。您的电子邮件地址确实作为您身份的一部分嵌入在提交日志等中,以及您指定的名称。例如,提交日志中的“作者”字段将显示为:
Author: Joe White <[email protected]>
So the information is available to anyone with a copy of the repo, since it acts as an identifier.
因此,任何拥有 repo 副本的人都可以使用该信息,因为它充当标识符。
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).
但是,垃圾邮件机器人可能看不到您的电子邮件,除非您使用 Gitweb 或 GitHub 之类的服务通过Web 界面使您的存储库可用(仅将其放在 Internet 上并不能这样做)。
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.
我想你可以填写一个虚假的电子邮件地址或使用一个空字符串或空格或其他东西(我认为 Git 不会检查电子邮件的格式或有效性),但是如果克隆 repo 的人需要发送电子邮件,则该电子邮件很有用你一个补丁或以某种方式联系你。
回答by VonC
Update April 2017
2017 年 4 月更新
See "Private emails, now more private"
请参阅“私人电子邮件,现在更加私密”
GitHub has supported using an alternate "noreply" email address to author web-based commits for a while now. Starting today, there's another way to ensure you don't inadvertently publish your email address when pushing commits to GitHub via the command line.
Git uses your email address to associate your name to any commits you author. Once you push your commits to a public repository on GitHub, the authorship metadata is published as well.
If you'd like to ensure you don't accidentally publish your email address, simply check the "Keep my email address private" and "Block command line pushes that expose my email" options in your email settings.
GitHub 支持使用备用的“noreply”电子邮件地址来创作基于 Web 的提交已有一段时间了。从今天开始,还有另一种方法可以确保您在通过命令行将提交推送到 GitHub 时不会无意中发布您的电子邮件地址。
Git 使用您的电子邮件地址将您的姓名与您创作的任何提交相关联。将提交推送到 GitHub 上的公共存储库后,也会发布作者元数据。
如果您想确保不会意外发布您的电子邮件地址,只需在您的电子邮件设置中选中“将我的电子邮件地址保密”和“阻止暴露我的电子邮件的命令行推送”选项。
Note: as commented belowby orev, Gitdoesn't expose anything. GitHub, a Git repositories hostingservice, might.
The place where you are pushing your local Git repo can expose metadata.
注:如评论下面通过OREV,Git的不公开什么。GitHub,一个 Git 存储库托管服务,可能会。
您推送本地 Git 存储库的位置可以公开元数据。
Note: Starting August, 9th 2013, you now can keep your email address private!
注意:从 2013 年 8 月 9 日起,您现在可以将您的电子邮件地址保密!
That is for web-based GitHub operations though: the commits still contain an email address, which could or could not be the same than the one used for your GitHub account.
See below to "mask" that (git commit) email too.
不过,这适用于基于 Web 的 GitHub 操作:提交仍包含一个电子邮件地址,该地址可能与用于您的 GitHub 帐户的电子邮件地址相同,也可能不同。
请参阅下文以“屏蔽”该(git commit)电子邮件。
Until today, all web-based GitHub Flow used your primary email address. This includes creating, editing, and deleting files, as well as merging pull requests.
But now you can keep your email address private. To do so, visit your email settings page:
直到今天,所有基于 Web 的 GitHub Flow 都使用您的主要电子邮件地址。这包括创建、编辑和删除文件,以及合并拉取请求。
但现在您可以将您的电子邮件地址保密。为此,请访问您的电子邮件设置页面:
With this turned on, web-based operations will use a [email protected] email address.
启用此功能后,基于 Web 的操作将使用 [email protected] 电子邮件地址。
If you want to hide your email made from your computer, GitHub now allows you to register different email addresses: see this guide.
如果您想隐藏从您的计算机创建的电子邮件,GitHub 现在允许您注册不同的电子邮件地址:请参阅本指南。
You still need to configure your (fake) email in your local repo before pushing back to GitHub, if you want your commits to reflect
如果您希望提交反映,您仍然需要在推送回 GitHub 之前在本地存储库中配置您的(假)电子邮件
git config --global user.email "[email protected]" # Set email to slightly changed value
git config --global user.email # Verify the setting
# [email protected]
Then:
然后:
- Go to the Emails setting menu
- Click "Add another email address"
- Enter the fake email (e.g. "
[email protected]
") and click "Add"
- 转到电子邮件设置菜单
- 点击“添加另一个电子邮件地址”
- 输入假电子邮件(例如“
[email protected]
”)并单击“添加”
Note that:
注意:
This setting only affects future commits.
If you want to erase your real email address from your repository's commit history, you will have to rewrite your old commits. The easiest way to do this is to:Use
git filter-branch
to rewrite the repository historyand Force-push the new history up.
此设置仅影响未来的提交。
如果您想从存储库的提交历史记录中删除真实的电子邮件地址,则必须重写旧的提交。最简单的方法是:使用
git filter-branch
重写历史资料库和强制推新的历史了。
回答by Hugo
GitHub has a help article called Keeping your email address private, which begins:
GitHub 有一篇名为Keeping your email address private的帮助文章,开头是:
Git requires you to identify yourself in order to make commits, but you can hide your contact information by using a fake address. Git itself doesn't care if the email is valid.
Good to know: Although Git does not care, some projects might not accept contributions from you if your commits do not have a valid email address, so you will want to research your project's contribution policies before following these instructions.
GitHub does not get many reports of spam being sent to Git commit email addresses, but if you are worried about it, this guide should help you address those concerns.
Git 要求您证明自己的身份才能进行提交,但您可以通过使用虚假地址来隐藏您的联系信息。Git 本身并不关心电子邮件是否有效。
很高兴知道:虽然 Git 不在乎,但如果您的提交没有有效的电子邮件地址,某些项目可能不会接受您的贡献,因此您需要在遵循这些说明之前研究项目的贡献政策。
GitHub 没有收到很多关于向 Git 提交电子邮件地址发送垃圾邮件的报告,但如果您对此感到担心,本指南应该可以帮助您解决这些问题。
The guide contains steps how to configure both Git and GitHub to use a fake address.
该指南包含如何配置 Git 和 GitHub 以使用假地址的步骤。
回答by bcolfer
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 "[email protected]"
You can also edit the .gitconfig file in your home directory, in the user section.
您还可以在用户部分的主目录中编辑 .gitconfig 文件。
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.
举个例子。
回答by g_fred
GitHub has a help section about setting your email address.
Specifically it says:
具体说:
Good to know: You don't have to give a valid email. If you're concerned about spam, use a fake email instead. [email protected] is a common practice.
很高兴知道:您不必提供有效的电子邮件。如果您担心垃圾邮件,请改用假电子邮件。[email protected] 是一种常见的做法。
回答by eggonlegs
You can retroactively change the author name, email etc. BEWARE that doing the following can corrupt your history.
您可以追溯更改作者姓名、电子邮件等。请注意,执行以下操作可能会破坏您的历史记录。
#!/bin/sh
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "[email protected]" ]
then
cn="Your New Committer Name"
cm="Your New Committer Email"
fi
if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ]
then
an="Your New Author Name"
am="Your New Author Email"
fi
export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"
'
Taken from here
取自这里
回答by Bombe
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)>”.
是的,您的电子邮件地址(如 中指定的git config user.email
)将在 GitWeb 等 Web 界面中可见。此外,每个人都可以通过克隆您的存储库来了解您的电子邮件地址,尽管这可能仍然远远超出垃圾邮件机器人的范围。不过,没有人强迫您使用真实的电子邮件地址。如果没有给出,Git 将自动设置一个构造的电子邮件地址。在我的机器上没有user.email
它显示“Foo <foo@daughter.(none)>”的提交。