致命:没有找到'XXX'的现有作者

问题描述 投票:35回答:3

我第一次使用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"

当我运行git commit --author "bob"时,我收到了错误fatal: No existing author found with 'bob'。如何设置用户名和电子邮件?

git git-commit git-config git-commands
3个回答
40
投票

您应该在每次提交时停止使用--author,而是使用git config配置作者。一旦你这样做,你可以输入git commit,作者将从你的.gitconfig文件中提取。

如果要为--author提供用于创作提交的名称,则需要使用

bob <[email protected]>

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


12
投票

这个命令可以解决这个问题:

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

4
投票

注意:从Git 2.3.1+开始(2015年第1季度/第2季度),错误消息将更加明确。 请参阅commit 1044b1fMichael J Gruber (mjg)

commit: reword --author error message

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

对于尝试指定有效的完整作者姓名的用户而言,这会让人感到困惑。

重命名错误消息,以便更清楚地知道故障在这种情况下有两个原因。

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

© www.soinside.com 2019 - 2024. All rights reserved.