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?
Just supplement:
git commit --author="[email protected] " -m "Impersonation is evil."
In some cases the commit still fails and shows you the following message:
*** Please tell me who you are.
Run
git config --global user.email "[email protected]" git config --global user.name "Your Name"
to set your account's default identity. Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got xxxx)
So just run "git config", then "git commit"
It is all dependent on how you commit.
For example:
git commit -am "Some message"
will use your ~\.gitconfig
username. In other words, if you open that file you should see a line that looks like this:
[user]
email = [email protected]
That would be the email you want to change. If your doing a pull request through Bitbucket or Github etc. you would be whoever you're logged in as.
The --author
option doesn't work:
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
This does:
git -c user.name='A U Thor' -c [email protected] commit
Open Git Bash.
Set a Git username:
$ git config --global user.name "name family" Confirm that you have set the Git username correctly:
$ git config --global user.name
name family
Set a Git email:
$ git config --global user.email [email protected] Confirm that you have set the Git email correctly:
$ git config --global user.email
Format
A U Thor <[email protected]>
simply mean that you should specify
FirstName MiddleName LastName <[email protected]>
Looks like middle and last names are optional (maybe the part before email doesn't have a strict format at all). Try, for example, this:
git commit --author="John <[email protected]>" -m "some fix"
As the docs say:
--author=<author>
Override the commit author. Specify an explicit author using the standard
A U Thor <[email protected]> format. Otherwise <author> is assumed to
be a pattern and is used to search for an existing commit by that author
(i.e. rev-list --all -i --author=<author>); the commit author is then copied
from the first such commit found.
if you don't use this format, git treats provided string as a pattern and tries to find matching name among the authors of other commits.
Run these two commands from the terminal to set User email and Name
git config --global user.email "[email protected]"
git config --global user.name "your name"
An alternative if the concern is to hide the real email address...If you are committing to Github you don't need a real email you can use <username>@users.noreply.github.com
Regardless of using Github or not, you probably first want change your committer details (on windows use SET GIT_...
)
GIT_COMMITTER_NAME='username'
GIT_COMMITTER_EMAIL='[email protected]'
Then set the author
git commit --author="username <[email protected]>"
https://help.github.com/articles/keeping-your-email-address-private
The specific format is:
git commit --author="John Doe <[email protected]>" -m "Impersonation is evil."
The minimal required author format, as hinted to in this SO answer, is
Name <email>
In your case, this means you want to write
git commit --author="Name <email>" -m "whatever"
Per Willem D'Haeseleer's comment, if you don't have an email address, you can use <>
:
git commit --author="Name <>" -m "whatever"
As written on the git commit
man page that you linked to, if you supply anything less than that, it's used as a search token to search through previous commits, looking for other commits by that author.
Source: Stackoverflow.com