18

working on a lab machine which has a shared login. don't want to set global git config parameters.

git commit --author="username <email>" 

This used to work on older git versions. now it produces this error:

*** 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 account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'blah@blah.(none)')

Any thoughts?

richmb
  • 1,325
  • 2
  • 13
  • 18

3 Answers3

15

What if you set the git config info just for the current repository?

  git config user.email "you@example.com"
  git config user.name "Your Name"

EDIT Based on OP comment a possible solution is:

GIT_AUTHOR_EMAIL="you@email.com" && GIT_AUTHOR_NAME="Your Name" && git commit
Aguardientico
  • 7,333
  • 1
  • 31
  • 32
  • 1
    Other people use the machine and the same repo. I guess I could set up the git config and then remove the configuration when I'm done. – richmb Apr 16 '15 at 20:37
  • @richmb I've edited the answer to maybe a best solution for you scenario – Aguardientico Apr 16 '15 at 20:52
  • 1
    You do not need the `&&` between variable definitions. Not even `dash` requires them. – Alexej Magura Jun 28 '21 at 18:52
  • I had the same issue and got it to work with git 2.17.1 by issuing `git config user.email "bogus@url.com"` and `git config user.name "Bogus"` Until I did that, it would not accept any `author=`, after that, the same command with `author=` worked and the author's name is not Bogus. – GlenPeterson Aug 05 '21 at 01:39
  • thanks, it worked – lord Feb 15 '22 at 20:31
5

First, With Git 2.29 (Q4 2020), the error message is clearer.

See commit 9ed104e (21 Aug 2020) by Junio C Hamano (gitster).
(Merged by Junio C Hamano -- gitster -- in commit e9bd00a, 31 Aug 2020)

ident: say whose identity is missing when giving user.name hint

If user.name and user.email have not been configured and the user invokes:

git commit --author=...  

without specifying the committer identity, then Git errors out with a message asking the user to configure user.name and user.email but doesn't tell the user which attribution was missing.

This can be confusing for a user new to Git who isn't aware of the distinction between user, author, and committer.

Give such users a bit more help by extending the error message to also say which attribution is expected.

The error message will clearly state:

Author identity unknown
# or
Committer identity unknown

Second, from OP's comment:

Other people use the machine and the same repo. I guess I could set up the git config and then remove the configuration when I'm done

You can wrap the git command and forcing each used to identify themselves (once per shell session).
See "Best pracitces for multi-developer Git for single user application" and my project VonC/gitw.

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
0

In Terminal:

  • git config --global user.email "nive54@gmail.com"
  • git config --global user.name "Nivetha"

Note:

GitHub registered email --> nive54@gmail.com

Your system name --> Nivetha (Refer to thispc->properties for this.)

Olivia Stork
  • 4,491
  • 5
  • 25
  • 39
Nivetha
  • 11