Git commit as another user without email or email only

I am trying to make some changes as another user, but I do not have a valid email address, the following command does not work 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 using only email address

 git commit --author="john@doe.com" -m "some fix" fatal: No existing author found with 'john@doe.com' 

The git man pages for the commit command say that I can use

 standard AU Thor <author@example.com> format 

For the --author parameter.

Where is this format defined? What does A and U mean? how can i commit for another user only with a username or only with an email?

+109
git commit
Jul 20 '12 at 12:23
source share
8 answers

AU Thor standard <author@example.com> Format

It seems to be defined as follows: (as far as I know, without any warranty)

AU Thor = required username

  • Separation of characters probably indicates that spaces are allowed, it can also resemble initials.
  • The username must be 1 space, additional spaces will be truncated

<author@example.com> = alternate email address

  • There should always be between <> characters.
  • The format of the email address is not verified, you can pretty much enter whatever you want.
  • Optionally, you can omit this explicitly using <>

If you do not use this exact syntax, git will search for existing commits and use the first commit containing your provided string.

<strong> Examples:

  • Username only

    Alert your email address explicitly:

     git commit --author="John Doe <>" -m "Impersonation is evil." 
  • Email only

    Technically, this is not possible. However, you can enter the email address as the username and explicitly omit the email address. It does not seem to be very useful. I think it would be even more useful to extract the username from the email address and then use it as the username. But if you need to:

     git commit --author="john@doe.com <>" -m "Impersonation is evil." 

I came across this when trying to convert a repository from mercury to git. I checked the commands on msysgit 1.7.10.

+30
Jul 23 '12 at 12:01
source share

The minimum author format required, as indicated in this SO answer ,

 Name <email> 

In your case, that means you want to write

 git commit --author="Name <email>" -m "whatever" 

Comment from Per Willem D'Haeseleer, 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 you linked to, if you supply something less, it is used as a search token to search for previous commits, looking for other commits of this author.

+128
Jul 20 2018-12-12T00:
source share

Specific format:

 git commit --author="John Doe <john@doe.com>" -m "Impersonation is evil." 
+44
Jul 20 '12 at 12:45
source share

Just add:

git commit --author = "john@doe.com" -m "Avatar is evil."

In some cases, the commit still does not work and displays the following message:

*** Please tell me who you are.

Run

git config --global user.email "you@example.com" git config --global user.name "your name"

to set your default account id. Omit --global to set the identifier only in this repository.

fatal: unable to automatically detect email address (received xxxx)

So just run git config, then git commit

+8
Jun 14 '13 at 2:09 on
source share

Format

 AU Thor <author@example.com> 

just means you have to specify

 FirstName MiddleName LastName <email@example.com> 

It seems that the surname and surname are not mandatory (perhaps the part before the letter does not have a strict format). Try for example the following:

 git commit --author="John <john@doe.com>" -m "some fix" 

As the docs say:

  --author=<author> Override the commit author. Specify an explicit author using the standard AU Thor <author@example.com> format. Otherwise <author> is assumed to be a pattern and is used to search for an existing commit by that author (ie rev-list --all -i --author=<author>); the commit author is then copied from the first such commit found. 

if you do not use this format, git treats the provided string as a template and tries to find a matching name among authors of other commits.

+6
Jul 20 2018-12-12T00:
source share

Open Git Bash.

Set your Git username:

$ git config --global user.name "name family" Confirm that you set the Git username correctly:

$ git config --global user.name

family name

Set your Git email address:

$ git config --global user.email email@foo.com Make sure you set your Git email address correctly:

$ git config --global user.email

email@foo.com

+2
Jun 08 '19 at 14:40
source share

Run these two commands from the terminal to set the email and username

  git config --global user.email "you@example.com" git config --global user.name "your name" 
0
Apr 21 '19 at 16:45
source share

If you are committing to Github, you do not need a real email address, you can use <username>@users.noreply.github.com

Regardless of whether you use Github or not, you will probably want to change your committer data first (when using Windows SET GIT_... )

 GIT_COMMITTER_NAME='username' GIT_COMMITTER_EMAIL='username@users.noreply.github.com' 

Then set the author

 git commit --author="username <username@users.noreply.github.com>" 

https://help.github.com/articles/keeping-your-email-address-private

-3
Aug 20 '14 at 2:49
source share



All Articles