public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail•com>
To: Matej Dujava <mdujava@kocurkovo•cz>,
	ZheNing Hu <adlternative@gmail•com>,
	git@vger•kernel.org, Junio C Hamano <gitster@pobox•com>,
	Jeff King <peff@peff•net>
Subject: Re: [PATCH] commit: add --committer option
Date: Mon, 17 Nov 2025 14:27:13 +0000	[thread overview]
Message-ID: <10ad6161-8d9d-4e07-ab62-105adac2220d@gmail.com> (raw)
In-Reply-To: <aRpMW-g_rt4jStnu@kocurkovo.cz>

On 16/11/2025 22:12, Matej Dujava wrote:
> 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.

>> 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.
>> 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.

> 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.
>>
>> 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


  reply	other threads:[~2025-11-17 14:27 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-09 10:22 [PATCH] commit: add --committer option ZheNing Hu via GitGitGadget
2025-11-10  9:24 ` Patrick Steinhardt
2025-11-10 14:17   ` ZheNing Hu
2025-11-10 17:38   ` Junio C Hamano
2025-11-11 13:19     ` ZheNing Hu
2025-11-10 16:50 ` Phillip Wood
2025-11-10 18:01   ` brian m. carlson
2025-11-10 20:11     ` Jeff King
2025-11-10 22:06       ` Junio C Hamano
2025-11-11  6:54       ` Patrick Steinhardt
2025-11-11 14:53         ` Phillip Wood
2025-11-12 16:11           ` ZheNing Hu
2025-11-11 13:42       ` ZheNing Hu
2025-11-11 19:15         ` Jeff King
2025-11-11 20:16           ` Junio C Hamano
2025-11-11 21:33             ` Jeff King
2025-11-11 21:58               ` Junio C Hamano
2025-11-11 22:23                 ` Jeff King
2025-11-12 16:51                   ` ZheNing Hu
2025-11-12 16:48                 ` ZheNing Hu
2025-11-12 16:46               ` ZheNing Hu
2025-11-12 16:41             ` ZheNing Hu
2025-11-12 16:37           ` ZheNing Hu
2025-11-11 13:01   ` ZheNing Hu
2025-11-11 14:38     ` Phillip Wood
2025-11-12 15:58       ` ZheNing Hu
2025-11-12 17:24         ` Junio C Hamano
2025-11-15  5:29           ` ZheNing Hu
2025-11-16  1:06             ` Junio C Hamano
2025-11-17 15:06               ` ZheNing Hu
2025-11-16 22:12         ` Matej Dujava
2025-11-17 14:27           ` Phillip Wood [this message]
2025-11-17 15:18             ` ZheNing Hu
2025-11-17 15:15           ` ZheNing Hu
2025-11-10 16:56 ` [PATCH v2] " ZheNing Hu via GitGitGadget
2025-11-10 19:22   ` Junio C Hamano
2025-11-10 19:29     ` Junio C Hamano
2025-11-11 13:36     ` ZheNing Hu
2025-11-11 15:40       ` Junio C Hamano
2025-11-12 16:23         ` ZheNing Hu
2025-11-12 16:55   ` [PATCH v3] " ZheNing Hu via GitGitGadget
2025-11-12 18:56     ` Junio C Hamano
2025-11-15  6:33       ` ZheNing Hu
2025-11-15 15:43     ` [PATCH v4] " ZheNing Hu via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10ad6161-8d9d-4e07-ab62-105adac2220d@gmail.com \
    --to=phillip.wood123@gmail$(echo .)com \
    --cc=adlternative@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=mdujava@kocurkovo$(echo .)cz \
    --cc=peff@peff$(echo .)net \
    --cc=phillip.wood@dunelm$(echo .)org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox