git 如何在 GitHub 上更改我的作者姓名?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5007135/
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
How do I change my author name on GitHub?
提问by oxo
I'm new to web development and GitHub. When I commit any changes, these changes are reflected on my GitHub repo under "unknown (author)". How do I change this to reflect my name/email address?
我是 Web 开发和 GitHub 的新手。当我提交任何更改时,这些更改会反映在我的 GitHub 存储库中的“未知(作者)”下。我如何更改它以反映我的姓名/电子邮件地址?
Thanks.
谢谢。
回答by Ori
$ git config --global user.name "Scott Chacon"
$ git config --global user.email "[email protected]"
回答by Lee Netherton
Add something like this to a file called ~/.gitconfig
(in your home directory):
将类似的内容添加到名为~/.gitconfig
(在您的主目录中)的文件中:
[user] name = USERNAME email = EMAIL_ADDRESS
where USERNAME
and EMAIL_ADDRESS
are filled in appropriately
whereUSERNAME
和EMAIL_ADDRESS
适当填写
回答by VonC
Note that starting Git 2.2 (Q3/Q4 2014), and commit 9830534by Matthieu Moy (moy
), you will be naturally guided to enter a user and email:
请注意,从 Git 2.2(2014 年第三季度/第四季度)开始,并由Matthieu Moy ( )提交 9830534,您将很自然地被引导输入用户和电子邮件:moy
config --global --edit
: create a template file if needed
config --global --edit
: 如果需要,创建一个模板文件
When the user has no
~/.gitconfig
file,git config --global --edit
used to launch an editor on an nonexistant file name.Instead, create a file with a default content before launching the editor.
The template contains only commented-out entries, to save a few keystrokes for the user. If the values are guessed properly, the user will only have to uncomment the entries.Advanced users teaching newbies can create a minimalistic configuration faster for newbies.
Beginners reading a tutorial advising to run "git config --global --edit
" as a first step will be slightly more guided for their first contact with Git.
当用户没有
~/.gitconfig
文件时,git config --global --edit
用于在不存在的文件名上启动编辑器。相反,在启动编辑器之前创建一个具有默认内容的文件。
该模板仅包含注释掉的条目,以便为用户保存一些击键。如果正确猜测值,用户只需取消对条目的注释。教授新手的高级用户可以更快地为新手创建简约的配置。
阅读建议将“git config --global --edit
”作为第一步的教程的初学者在他们第一次接触 Git 时会得到更多的指导。
If you put your GitHub username and email account in those settings, your commits will accurately reflect your GitHub account as the right author.
如果您将您的 GitHub 用户名和电子邮件帐户放在这些设置中,您的提交将准确地将您的 GitHub 帐户反映为正确的作者。
Note that the user.name and email are guessed and put in that /.gitconfig file, as per commit 8b27ff7:
请注意,根据提交 8b27ff7猜测 user.name 和 email 并将其放入该 /.gitconfig 文件中:
commit: advertise config --global --edit
on guessed identity
提交:config --global --edit
在猜测的身份上做广告
When the user has no user-wide configuration file, it's faster to use the newly introduced config file template than to run two commands to set
user.name
anduser.email
. Advise this to the user.The old advice is kept if the user already has a configuration file since the template feature would not trigger in this case.
当用户没有用户范围的配置文件时,使用新引入的配置文件模板比运行两个命令设置
user.name
和user.email
. 将此建议给用户。如果用户已有配置文件,则保留旧建议,因为在这种情况下不会触发模板功能。
New advice:
新建议:
Your name and email address were configured automatically based on your username and hostname.
Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the following command and follow the instructions in your editor to edit your configuration file:"
您的姓名和电子邮件地址是根据您的用户名和主机名自动配置的。
请检查它们是否准确。
您可以通过显式设置它们来抑制此消息。运行以下命令并按照编辑器中的说明编辑配置文件:”
git config --global --edit
After doing this, you may fix the identity used for this commit with:
执行此操作后,您可以使用以下命令修复用于此提交的身份:
git commit --amend --reset-author
回答by Jishnu Dey
Git uses your username to associate commits with an identity. The git config command can be used to change your Git configuration, including your username. Here is a good guide available: https://help.github.com/articles/setting-your-username-in-git/
Git 使用您的用户名将提交与身份相关联。git config 命令可用于更改您的 Git 配置,包括您的用户名。这里有一个很好的指南:https: //help.github.com/articles/setting-your-username-in-git/