You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gh pr merge: default to git user.email for merge commit #8590
Describe the feature or problem you’d like to solve
With multiple emails on my GitHub account, I have git configured to automatically change the email address used for commits to work repos to my work email and vice versa. However, gh pr merge uses my account's primary email address rather than respecting my git configuration. For example, if the primary email on the account is [email protected] and git config user.email returns [email protected], gh pr merge will still create the merge commit with [email protected] as the email address. On the GitHub website, merging a PR defaults to my default email for the organization/repository, I think.
Proposed solution
Perhaps gh pr merge could check if the email address for the current repo is configured to something other than the default?
Additional context
If it matters, my email is sometimes specified in .git/config, but other times it is not--I have git configured globally to automatically change the email address used for repositories matching work URL patterns. In either case, git config user.email would return the correct one for the local repository.
Reacted by Glyph, Daniel Compton, Jeffery, Jérôme Bertaux, Felix B, Nicolò Lucchesi and walkure
Alas, in my ideal world, the commit would be made locally (as if I had manually done the merge), but it does make sense that it's not, I just wish I didn't have to specify -A all the time for this.
Hey @willeccles thanks for opening this issue and sorry for the delay in responding after Christmas vacation. Some team changes and a large backlog. There's definitely room for improvement in this flow, particularly with the multi-account support that landed before Christmas.
There have been a few discussions around email linked below but most specifically there has been a PR closed by previous maintainers that tried to add this support: #5229
Given the discomfort with introducing implicit coupling with a git config value, we've decided to close this; however, we'd consider a new PR adding a flag to pr merge for setting author info.
Sadly, none of the maintainers that were around when that decision was made are still involved the project, so I'm not sure what their discomfort really involved. If I were to guess, I would say that the issue relates to potentially having a global git configuration set, or even a conditional configuration set (e.g. work vs personal) that has a totally different email to what you might expect. It could additionally be surprising behaviour for everyone if their emails suddenly changed under their feet.
However, it's clearly a desired feature. I wonder whether there might be a path to support this with a gh specific configuration so that it could be opted into. What do you think?
Hi @williammartin, I agree that it sounds like perhaps a gh specific configuration option might be a good solution--perhaps an option to enable it to fall back to git configuration to determine the email address? From the issues you linked, it seems that this is indeed desired behavior, but it sounds like perhaps the original maintainers were also correct that this should not be default behavior.
Activity
sophec commentedon Jan 17, 2024
Alas, in my ideal world, the commit would be made locally (as if I had manually done the merge), but it does make sense that it's not, I just wish I didn't have to specify
-Aall the time for this.williammartin commentedon Feb 21, 2024
Hey @willeccles thanks for opening this issue and sorry for the delay in responding after Christmas vacation. Some team changes and a large backlog. There's definitely room for improvement in this flow, particularly with the multi-account support that landed before Christmas.
There have been a few discussions around email linked below but most specifically there has been a PR closed by previous maintainers that tried to add this support: #5229
Sadly, none of the maintainers that were around when that decision was made are still involved the project, so I'm not sure what their discomfort really involved. If I were to guess, I would say that the issue relates to potentially having a global git configuration set, or even a conditional configuration set (e.g. work vs personal) that has a totally different email to what you might expect. It could additionally be surprising behaviour for everyone if their emails suddenly changed under their feet.
However, it's clearly a desired feature. I wonder whether there might be a path to support this with a
ghspecific configuration so that it could be opted into. What do you think?Some further reading:
sophec commentedon Feb 21, 2024
Hi @williammartin, I agree that it sounds like perhaps a
ghspecific configuration option might be a good solution--perhaps an option to enable it to fall back to git configuration to determine the email address? From the issues you linked, it seems that this is indeed desired behavior, but it sounds like perhaps the original maintainers were also correct that this should not be default behavior.