git/list[1] front-page[2] threads[3] people[4] search[5] about
 

--author arg on commit only works if there is an email configured already

From
AAAlvaro Aleman <aaleman@redhat.com>
Date
Aug 21, 2020, 16:15 UTC
Message-ID
<CAOW=8D2J3t3cE32q2xNqSOPTa6gxR5gSuJUCCj5MSj58ccc3Cg@mail.gmail.com>
Hello everyone,

It seems the `--author` arg on the `git commit` command only works if an author email is configured already somewhere:

Sample that I would expect to work and that does not work:

``` $ docker run --rm -it golang /bin/bash -c 'cd $(mktemp -d); git init; touch test; git add test; git commit -m message --author "A U Thor <author@example.com>"' Initialized empty Git repository in /tmp/tmp.TiNqOZsw9C/.git/

*** 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 'root@aedfbe0df193.(none)') ```

When configuring any mail first, this works and uses the mail specified in the `--author` arg:

```
$ docker run --rm -it golang /bin/bash -c 'cd $(mktemp -d); git init;
touch test; git add test; git config --local user.email
"mail@domain.com"; git commit -m message --author "A U Thor
<author@example.com>"'
Initialized empty Git repository in /tmp/tmp.1drhE2Rgmh/.git/
[master (root-commit) b3dad37] message
 Author: A U Thor <author@example.com>
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test
```

The git version: $ docker run --rm -it golang git --version git version 2.20

Next: Andreas Schwab
Message 1 of 10 in “--author arg on commit only works if there is an email configured already”
  1. Alvaro AlemanAug 21, 2020
  2. Andreas SchwabAug 21, 2020
  3. Junio C HamanoAug 21, 2020
  4. Alvaro AlemanAug 21, 2020
  5. ident: say whose identity is missing when giving user.name hintJunio C Hamano, Aug 21, 2020
  6. Eric SunshineAug 21, 2020
  7. Junio C HamanoAug 21, 2020
  8. Alvaro AlemanAug 21, 2020
  9. Eric SunshineAug 21, 2020
  10. Junio C HamanoAug 21, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.