git 刚开始使用 TortoiseGit,为什么本地存储库需要我的电子邮件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21049090/
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
Just starting with TortoiseGit, why does it need my email for a local repository?
提问by Sheldon Pinkman
I just installed Git + TortoiseGit, created a new local repository on my PC, added a file, and now I'm trying to commit it (I guess that's Commit -> "master").
我刚刚安装了 Git + TortoiseGit,在我的 PC 上创建了一个新的本地存储库,添加了一个文件,现在我正在尝试提交它(我猜是 Commit -> “master”)。
However it says: "User name and email must be set before commit. Do you want to set these now?"
但是它说:“必须在提交之前设置用户名和电子邮件。你想现在设置这些吗?”
Ehh, this is supposed to be a local repository. What does any email address have to do with this?
呃,这应该是一个本地存储库。任何电子邮件地址与此有什么关系?
Or am I misunderstanding the way Git works? Note that I'm not using GitHub or BitBucket or whatever. Just a local repository.
还是我误解了 Git 的工作方式?请注意,我没有使用 GitHub 或 BitBucket 或其他任何东西。只是一个本地存储库。
回答by Abizern
The name and email are added to the commit by Git. It's not related to login credentials. It's useful to set at least the name, even if you don't want to set your email.
名称和电子邮件由 Git 添加到提交中。它与登录凭据无关。至少设置名称很有用,即使您不想设置电子邮件。
If you want to leave them blank then you can enter these commands in a terminal:
如果您想将它们留空,则可以在终端中输入这些命令:
git config --global user.name ""
git config --global user.email ""
which should create a ~/.gitconfig
file at your system's $HOME, which will look like:
它应该~/.gitconfig
在您系统的 $HOME 中创建一个文件,如下所示:
[user]
name =
email =
Alternatively, just create or edit your current ~/.gitconfig file to look like this.
或者,只需创建或编辑当前的 ~/.gitconfig 文件,使其看起来像这样。
回答by Duther
In Git both a username and a mail address are associated to each commit, even for local repositories (In fact, in Git, all repositories are arguably local).
在 Git 中,用户名和邮件地址都与每个提交相关联,即使对于本地存储库也是如此(实际上,在 Git 中,所有存储库都可以说是本地的)。
It is, however, simply used as a label. It won't send you any mail. If you are concerned with your privacy, or you simply don't want to write your real e-mail for whatever reason, you can enter a fake one and it will cause no issues.
然而,它只是用作标签。它不会向您发送任何邮件。如果您担心自己的隐私,或者出于任何原因根本不想写真实的电子邮件,则可以输入假电子邮件,这不会造成任何问题。
In fact, this is precissely the approach recommended by GitHub for users with privacy concerns (https://help.github.com/articles/keeping-your-email-address-private).
事实上,这正是 GitHub 为有隐私问题的用户推荐的方法(https://help.github.com/articles/keeping-your-email-address-private)。