Issue
I’m trying to commit some changes as a different user, but i do not have a valid email address, following command is not working for me:
git commit --author="john doe" -m "some fix"
fatal: No existing author found with 'john doe'
I have the same problem when trying to commit with only an email address
git commit --author="[email protected]" -m "some fix"
fatal: No existing author found with '[email protected]'
On the GIT man pages for the commit command it says i can use the
standard A U Thor <[email protected]> format
For the –author option.
Where is this format defined ?
what does A and U stand for ? how do i commit for a different user with only a username or only an email?
Solution
The
standard A U Thor <[email protected]> format
Seems to be defined as followed:
( as far as i know, with absolutely no warranty )
A U Thor = required username
- The separation of the characters probably indicates that spaces are allowed, it could also be resembling initials.
- The username has to be followed by 1 space, extra spaces will be truncated
<[email protected]> = optional email address
- Must always be between < > signs.
- The email address format isn’t validated, you can pretty much enter whatever you want
- Optional, you can omit this explicitly by using <>
If you don’t use this exact syntax, git will search through the existing commits and use the first commit that contains your provided string.
Examples:
-
Only user name
Omit the email address explicitly:
git commit --author="John Doe <>" -m "Impersonation is evil."
-
Only email
Technically this isn’t possible. You can however enter the email address as the username and explicitly omit the email address. This doesn’t seem like it’s very useful.
I think it would make even more sense to extract the user name from the email address and then use that as the username. But if you have to:git commit --author="[email protected] <>" -m "Impersonation is evil."
I ran in to this when trying to convert a repository from mercurial to git.
I tested the commands on msysgit 1.7.10.
Answered By – Willem D'Haeseleer
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0