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
KKKonstantin Khomoutov <kostix@bswap.ru>
Date
Feb 9, 2024, 08:21 UTC
Message-ID
<20240209082133.jzldo5diog2fd4en@carbon>
In-Reply-To
<60512662-9BE1-4DF7-A4E0-FD2E852E8E76@qt.io>
On Fri, Feb 09, 2024 at 07:43:01AM +0000, Marcus Tillmanns wrote:
Show 6 quoted lines
> Uff, that’s a mean trap. Especially since there is no “--committer” option
> as far as I can see. Also the difference between the two error messages is
> just one (the first) word.
> 
> Maybe that could be made more obvious, especially if the user specifies
> “--author” already.

There's a way to specify the author and e-mail on the command-line during a single invocation:

  git -c user.name=marcus -c user.email=user@example.com commit ...

This "-c" command-line option is explained in the "root" Git manual page (run `git help git` for instance).

The reasoning behind having different author and committer is that Git has been created to handle the development of Linux where most of the code flowed (and still does, I presume) in in the form of patches sent to a set of mailing lists, so the person creating a Git commit out of such a patch in most cases not the person who has authored the change introduced by the patch (the author).

Also note that you do not have to set the name and e-mail globally: Git has three levels of configuration, one of which is "local" meaning it's stored in the repository's metadata. So you can basically run

  git config --local --add user.name marcus

to have this setting apply only to the repository which you "are in" currently. This value will override any "global" (per-user) settings and any "system" settings.

Previous: Marcus TillmannsNext: Kristoffer Haugsbakk
Message 4 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.