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

Re: [PATCH] commit: add --committer option

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Nov 17, 2025, 14:27 UTC
Message-ID
<10ad6161-8d9d-4e07-ab62-105adac2220d@gmail.com>
In-Reply-To
<aRpMW-g_rt4jStnu@kocurkovo.cz>
On 16/11/2025 22:12, Matej Dujava wrote:
Show 23 quoted lines
> On Wed, Nov 12, 2025 at 11:58:02PM +0800, ZheNing Hu wrote:
>> Phillip Wood <phillip.wood123@gmail.com> 于2025年11月11日周二 22:38写道:
> 
> I use includeIf pattern in a config to separate identities
> 
> ~/.gitconfig:
> ```
>   [includeIf "gitdir:~/.local/src/personal/"]
>       path ~/.gitconfig-personal
>   [includeIf "gitdir:~/.local/src/companyA/"]
>       path ~/.gitconfig-companyA
>   [includeIf "gitdir:~/.local/src/companyB/"]
>       path ~/.gitconfig-companyB
> ```
> 
> then each
> ~/.gitconfig-IDENTITY:
> ```
>   [user]
>       name = ...
>       email = ...
>       signingkey = ...
> ```

I think that's a common pattern, so long as one can arrange the directory structure so that the repositories for each identity are under a different sub-directory it works well.

Show 10 quoted lines
>> You're right that after realizing the misconfiguration and correcting the
>> repository's user.name and user.email, running `git commit --amend` will
>> fix the committer information, but the author remains unchanged. Users
>> then need an additional `git commit --amend --author=...` to fix the 
>> author,
>> which does work but requires an extra step.
> 
> For just one commit, after you fix identity (update .git/config or move
> project so includeIf uses correct config) then `git commit --amend
> --reset-author` should get right identity for both commiter and author.

As you note below it also resets the author date which might to be desirable.

Show 11 quoted lines
>> I see your point that this becomes more cumbersome when dealing with
>> multiple commits. In such cases, users currently need to use something 
>> like:
>>
>> ```
>> GIT_AUTHOR_NAME="..." GIT_AUTHOR_EMAIL="..." \
>> GIT_COMMITTER_NAME="..." GIT_COMMITTER_EMAIL="..." \
>> git rebase -f <target>
>> ```
> 
> In my test ^ (using 2.51.2) did not set specified AUTHOR identity

Indeed, rebase sets GIT_AUTHOR_{NAME,EMAIL,DATE} when running "git commit" to preserve the authorship of the commit being picked so any value that is set in the environment when running "git rebase" is ignored.

Show 8 quoted lines
> but using:
> 
>    git rebase <target> -fx "git commit --amend --no-edit --reset-author"
> 
> is close to rewriting commits with new identity, but this will change
> both dates (committer, author).
> If --reset-author is not used but either GIT_AUTHOR_* are exported or
> --author '...' is used in a -x arg, then author date is kept untouched.

Yes "git rebase -x 'git commit --author=... --amend --no-edit'" is probably the easiest way to reset the author and committer.

Show 10 quoted lines
>>
>> This is indeed tedious and error-prone, especially when you want
>> to quickly fix and push commits to the platform.
>>
>> `git commit --amend --author --committer` or a new `git rebase
>> --author --committer`
>> would provide a more user-friendly workflow for correcting identity
>> information after misconfiguration, eliminating the need to manually
>> set multiple
>> environment variables or run multiple commands.

I'm still not sure why we need a "--committer" option when the committer identity is taken from the corrected config anyway.

Thanks
Phillip
Previous: Matej DujavaNext: ZheNing Hu
Message 32 of 44 in “commit: add --committer option”
  1. commit: add --committer optionZheNing Hu via GitGitGadget, Nov 9, 2025
  2. Patrick SteinhardtNov 10, 2025
  3. ZheNing HuNov 10, 2025
  4. Junio C HamanoNov 10, 2025
  5. ZheNing HuNov 11, 2025
  6. Phillip WoodNov 10, 2025
  7. brian m. carlsonNov 10, 2025
  8. Jeff KingNov 10, 2025
  9. Junio C HamanoNov 10, 2025
  10. Patrick SteinhardtNov 11, 2025
  11. Phillip WoodNov 11, 2025
  12. ZheNing HuNov 12, 2025
  13. ZheNing HuNov 11, 2025
  14. Jeff KingNov 11, 2025
  15. Junio C HamanoNov 11, 2025
  16. Jeff KingNov 11, 2025
  17. Junio C HamanoNov 11, 2025
  18. Jeff KingNov 11, 2025
  19. ZheNing HuNov 12, 2025
  20. ZheNing HuNov 12, 2025
  21. ZheNing HuNov 12, 2025
  22. ZheNing HuNov 12, 2025
  23. ZheNing HuNov 12, 2025
  24. ZheNing HuNov 11, 2025
  25. Phillip WoodNov 11, 2025
  26. ZheNing HuNov 12, 2025
  27. Junio C HamanoNov 12, 2025
  28. ZheNing HuNov 15, 2025
  29. Junio C HamanoNov 16, 2025
  30. ZheNing HuNov 17, 2025
  31. Matej DujavaNov 16, 2025
  32. Phillip WoodNov 17, 2025
  33. ZheNing HuNov 17, 2025
  34. ZheNing HuNov 17, 2025
  35. commit: add --committer optionZheNing Hu via GitGitGadget, Nov 10, 2025
  36. Junio C HamanoNov 10, 2025
  37. Junio C HamanoNov 10, 2025
  38. ZheNing HuNov 11, 2025
  39. Junio C HamanoNov 11, 2025
  40. ZheNing HuNov 12, 2025
  41. commit: add --committer optionZheNing Hu via GitGitGadget, Nov 12, 2025
  42. Junio C HamanoNov 12, 2025
  43. ZheNing HuNov 15, 2025
  44. commit: add --committer optionZheNing Hu via GitGitGadget, Nov 15, 2025

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.