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

Re: Bug: Commit fails when no global email address is set even though --author is used

From
Kristoffer Haugsbakk <code@khaugsbakk.name>
Date
Feb 9, 2024, 08:37 UTC
Message-ID
<3c3db003-1506-47c4-a010-a8b783dff959@app.fastmail.com>
In-Reply-To
<60512662-9BE1-4DF7-A4E0-FD2E852E8E76@qt.io>
On Fri, Feb 9, 2024, at 08:43, Marcus Tillmanns wrote:
> Uff, that’s a mean trap. Especially since there is no “—committer”
> option as far as I can see.
Your report would have been more clear if you included the error:

``` $ git commit -m "Test" --author "My Name <my@email.com>" Committer identity unknown

*** 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 '<machine>') ```

I guess there is no `--committer` since there are use-cases for attributing the commit to someone else (like you just received a patch or diff from someone) but there isn’t really a common use-case for attributing the committer to someone else—the point of the “committer” is to identify who did the commit itself.

And the error tells you about something that you would want to do in any case. Because passing in the committer with

``` GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL ```

every time is a lot of work.

I guess the most common workflow is to configure your user globally. But it’s often the case that you might have a work identity (like the email). What I do is to try to remember to configure it locally in those repositories as well. But in the most recent case I forgot about it and had to rewrite the commits. :) So an alternative is to not set any global user. And then you will get this complaint every time you start work in a new repository:

``` Committer identity unknown

*** Please tell me who you are. ```

And then you can copy–paste one of your identities into the local config. And be certain that you won’t make any commits with the wrong identity.

That’s more work but also safer.

So I guess that “Please tell me who you are” might be a part of some peoples’ usual repository setup workflow.

-- 
Kristoffer Haugsbakk
Previous: Konstantin KhomoutovNext: Marcus Tillmanns
Message 5 of 13 in “Bug: Commit fails when no global email address is set even though --author is used”
  1. Marcus TillmannsFeb 8, 2024
  2. Phillip WoodFeb 8, 2024
  3. Marcus TillmannsFeb 9, 2024
  4. Konstantin KhomoutovFeb 9, 2024
  5. Kristoffer HaugsbakkFeb 9, 2024
  6. Marcus TillmannsFeb 9, 2024
  7. Kristoffer HaugsbakkFeb 9, 2024
  8. Junio C HamanoFeb 9, 2024
  9. Kristoffer HaugsbakkFeb 9, 2024
  10. Junio C HamanoFeb 9, 2024
  11. Marcus TillmannsFeb 10, 2024
  12. Junio C HamanoFeb 10, 2024
  13. Kristoffer HaugsbakkFeb 11, 2024

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.