fatal: No existing author found with 'XXX'

你说的曾经没有我的故事 提交于 2019-12-03 08:58:19

问题


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

git config --global user.email "bob@example.com"
git config user.email "bob@example.com"
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?


回答1:


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

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

bob <bob@example.com>

not just bob. If your author string doesn't match the user <user@example.com> 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 <user@example.com> as the author.




回答2:


This command will do the trick:

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



回答3:


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

commit: reword --author error message

If an --author argument 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.

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



来源:https://stackoverflow.com/questions/26318375/fatal-no-existing-author-found-with-xxx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!