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?
This command will do the trick:
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
):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.You should stop using
--author
each time you commit, and instead configure an author withgit config
. Once you've done so, you can typegit 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 usebob <bob@example.com>
not just
bob
. If your author string doesn't match theuser <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'suser <user@example.com>
as the author.