我应该为 git user.name 使用什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14014964/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:55:35  来源:igfitidea点击:

What should I use for git user.name?

gitgithub

提问by toxalot

I'm very new to Git and have never used any VCS before. I just opened a GitHub account. I started out by reading the GitHub help pages. I downloaded and installed Git on my local Windows machine. From there, I was directed to the Pro Git book. During the initial setup I used my proper legal name.

我对 Git 很陌生,以前从未使用过任何 VCS。我刚刚开设了一个 GitHub 帐户。我从阅读 GitHub 帮助页面开始。我在本地 Windows 机器上下载并安装了 Git。从那里,我被引导到 Pro Git 书。在初始设置期间,我使用了我的正确合法名称。

I've done so much reading about Git and GitHub in the last little bit that I can't remember where I read what. I thought I read something somewhere (but can't find it now) that said I should use my GitHub usernameas my Git user.name. So now I am not sure what to do.

我在最后一点点读了很多关于 Git 和 GitHub 的文章,以至于我不记得我在哪里读到了什么。我以为我在某处读到了一些东西(但现在找不到),上面说我应该使用我的 GitHub用户名作为我的 Git user.name。所以现在我不知道该怎么做。

I've read this Pro Git pagewhich says:

我读过这个 Pro Git 页面,它说:

$ git config --global user.name "John Doe"

$ git config --global user.name "John Doe"

And I've read this GitHub pagewhich says:

我已经阅读了这个 GitHub 页面,它说:

$ git config --global user.name "Your Name Here"

$ git config --global user.name "你的名字在这里"

The first implies that one should use their proper name, the second is unclear. However, the GitHub page also has the following to say:

第一个暗示一个人应该使用他们的专有名称,第二个不清楚。不过,GitHub 页面也有以下内容要说:

We use the email address to associate your commits with your GitHub account.

我们使用电子邮件地址将您的提交与您的 GitHub 帐户相关联。

What I take from that is that the user.emailis important if I want my commits linked to my GitHub account. Since it doesn't say anything about the name, I'm thinking that maybe it doesn't matter.

我从中得到的是,如果我希望将提交链接到我的 GitHub 帐户,则user.email很重要。由于它没有说明名称,我想也许这无关紧要。

So what should I be using for my Git user.name?

那么我的 Git user.name应该使用什么?

回答by Jake A. Smith

You can use your proper name, username or whatever identifier you'd like for user.name. It will be logged in each commit along with your email address, commit message and various other details. And you're exactly right about how GitHub uses the email address. Good luck with git! You're on the right track with Pro Git.

您可以为 user.name 使用您的专有名称、用户名或任何您喜欢的标识符。它将与您的电子邮件地址、提交消息和各种其他详细信息一起记录在每次提交中。您对 GitHub 使用电子邮件地址的方式完全正确。祝 git 好运!您在使用 Pro Git 时走在正确的轨道上。

回答by Sebastian

As the field says, use it for your name. You can set your email in the user.emailsettings key. Github also uses email for displaying your global avatar image from the Gravatar service. I prefer to set my full name / email in global config, but you can set project-specific config, too. By default with all your repos will use the global setting (e.g. "John Doe"), unless you explicitly override it with a local setting (e.g. toxalot).

正如该字段所说,将其用作您的名字。您可以在user.email设置键中设置您的电子邮件。Github 还使用电子邮件来显示来自 Gravatar 服务的全局头像图像。我更喜欢在全局配置中设置我的全名/电子邮件,但您也可以设置特定于项目的配置。默认情况下,您的所有存储库都将使用全局设置(例如“John Doe”),除非您使用本地设置(例如 toxalot)明确覆盖它。

回答by Luigi R. Viggiano

There is 'user.email' for the email. I use both, and they both get logged in the commits.

电子邮件有“user.email”。我同时使用两者,并且它们都记录在提交中。