git 致命:没有找到带有“XXX”的现有作者

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

fatal: No existing author found with 'XXX'

gitgit-commitgit-configgit-commands

提问by meagar

I used git for the first time and I set my user name and user mail. The commands I used are below:

我第一次用git,设置了我的用户名和用户邮箱。我使用的命令如下:

git config --global user.email "[email protected]"
git config user.email "[email protected]"
git config --global user.name "bob"
git config user.name "bob"

When I run git commit --author "bob", I got an error fatal: No existing author found with 'bob'. How can I set user name and email?

当我运行时git commit --author "bob",出现错误fatal: No existing author found with 'bob'。如何设置用户名和邮箱?

回答by meagar

You should stop using --authoreach time you commit, and instead configure an author with git config. Once you've done so, you can type git commitand the author will be pulled from your .gitconfigfile.

您应该在--author每次提交时停止使用,而是使用git config. 完成后,您就可以输入git commit了,作者将从您的.gitconfig文件中提取出来。

If you want to give --authora name to use for authoring the commit, you need to use

如果你想给--author一个名称用于创作提交,你需要使用

bob <[email protected]>

bob <[email protected]>

not just bob. If your author string doesn't match the user <[email protected]>format, Git assumes you've given it a search pattern, and it will try to find commits with matching authors. It will use the first found commit's user <[email protected]>as the author.

不只是bob。如果你的作者字符串与user <[email protected]>格式不匹配,Git 会假设你已经给了它一个搜索模式,它会尝试找到具有匹配作者的提交。它将使用第一个找到的提交user <[email protected]>作为作者。

回答by Ivan Voroshilin

This command will do the trick:

这个命令可以解决问题:

git commit --amend -C HEAD --reset-author

回答by VonC

Note: starting with Git 2.3.1+ (Q1/Q2 2015), the error message will be more explicit.
See commit 1044b1fby Michael J Gruber (mjg):

注意:从 Git 2.3.1+(2015 年第一季度/第二季度)开始,错误消息将更加明确。
提交1044b1f迈克尔·格鲁伯Ĵ( )mjg

commit: reword --authorerror message

If an --authorargument is specified but does not contain a '>' then git tries to find the argument within the existing authors; and gives the error message "No existing author found with '%s'" if there is no match.

This is confusing for users who try to specify a valid complete author name.

Rename the error message to make it clearer that the failure has two reasons in this case.

commit: 改写--author错误信息

如果--author指定了参数但不包含“ >”,则 git 尝试在现有作者中查找参数;No existing author found with '%s'如果没有匹配项,则给出错误消息“ ”。

这对于尝试指定有效的完整作者姓名的用户来说是令人困惑的。

重命名错误消息以更清楚地表明在这种情况下失败有两个原因。

The solution remains to have the config user.name and user.email properly set, but for the case where --authoris used, at least the expected argument is now clearer.

解决方案仍然是正确设置配置 user.name 和 user.email,但对于使用的情况--author,至少预期的参数现在更清晰。