Re: [PATCH] commit: add --committer option
- From
ZheNing Hu <adlternative@gmail.com>
- Date
- Nov 17, 2025, 15:15 UTC
- Message-ID
- <CAOLTT8SOSV48PA-4F3QuHTJQNB_O=Ne8G8JmRTg_uvBypjFeJw@mail.gmail.com>
- In-Reply-To
- <aRpMW-g_rt4jStnu@kocurkovo.cz>
Matej Dujava <mdujava@kocurkovo.cz> 于2025年11月17日周一 06:12写道:
Show 70 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写道:
> >>
> >> On 11/11/2025 13:01, ZheNing Hu wrote:
> >> > Phillip Wood <phillip.wood123@gmail.com> 于2025年11月11日周二 00:50写道:
> >> >> On 09/11/2025 10:22, ZheNing Hu via GitGitGadget wrote:
> >> >>> From: ZheNing Hu <adlternative@gmail.com>
> >> >>>
> >> >>>
> >> >>> This patch introduces the --committer option to git-commit, providing:
> >> >>>
> >> >>> 1. Consistency with the existing --author option
> >> >>> 2. A more convenient alternative to environment variables
> >> >>> 3. Better support for automated workflows and scripts
> >> >>> 4. Improved user experience when managing multiple identities
> >> >>
> >> >> What's the use case for the same person committing under different
> >> >> identities? We already have a config mechanism to set different
> >> >> identities for different repositories but I'm struggling to see why
> >> >> someone would want to create commits under multiple identities in a
> >> >> single repository. For scripts it easy enough to set the relevant
> >> >> environment variables if a tool wants to create commits under its own
> >> >> identity.
> >> >>
> >> >
> >> > I frequently need to distinguish between different user.name and user.email
> >> > configurations on our company's internal GitHub.
> >> >
> >> > The current problems are:
> >> >
> >> > When I misconfigure (which happens occasionally), git commit --author only fixes
> >> > the author part, I still need to additionally set GIT_COMMITTER_NAME and
> >> > GIT_COMMITTER_EMAIL environment variables to fix the committer information
> >> > These environment variables are painful to use, requiring manual setup
> >> > every time
> >>
> >> I'm afraid I don't quite follow. If you are amending existing commits to
> >> fix them up after you have corrected your configuration then they will
> >> have the correct committer automatically when you run "git commit
> >> --amend --author=..." to correct the author. If you are committing
> >> before you have realized that user.{name,email} are misconfigured then I
> >> don't see how "--committer" helps because you have not yet realized
> >> anything is wrong.
> >>
> >
>
> Hi
>
> 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 = ...
> ```
>This does indeed appear to be a very good standard, but unfortunately many users in the past and possibly even in the future may not be aware of such a good practice.
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. >
Ok...
Show 21 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, 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. >
This does look like a good approach indeed, and it should pretty much meet the user's requirements.
Show 24 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. > > > >> Thanks > >> > >> Phillip > >> > > > >Thanks > > > >ZheNing Hu > > > > -- > Thanks, > Matej