Skip to content

Wrong git author when merging a pull request using gh #3032

Closed

Description

@mrolli

Describe the bug

I fell in love with your cli tool It's bodacious and speeds up the workflow tremendously!

When using gh to merge a pull request using gh pr merge <no> and requesting a merge commit, the merge commit was not carried out with the commit author set in .git/config of the working copy where the merge happens. Which git author settings (user.name/user.email) are actually taken when directly merging with gh? Local global (~/.gitconfig) or the primary address of the github account?

$ gh --version
gh version 1.6.1 (2021-02-18)
https://github.com/cli/cli/releases/tag/v1.6.1

Steps to reproduce the behavior

  1. Let the email address differ in ~/.gitconfig, local working copy and primary account at github.com
  2. Merge a pull request using gh
  3. Verify the commit message of the merge commit

Expected vs actual behavior

As a user in different orgs, when having user.email set to

  1. [email protected] in ~/.gitconfig
  2. [email protected] as the primary email address in the github.com profile (but also having [email protected] as an additional email address there)
  3. [email protected] in .git/config of the current working copy in question,

I expect the merge to be carried out by the email.name/email.user pair set in local .git/config - the same that git would use. But that is not what happens. [email protected] hab been taken for the merge commit, when merging the pull request using gh pr merge <no>.
As my primary account address at github is the same as in ~/.gitconfig, I can't say which one of the two is taken, but I assume it's the primary account address and first/last name of the github account, isn't it?

Activity

  1. added
    bug
    on Feb 24, 2021
  2. mrolli commented on Feb 24, 2021

    @mrolli
    Author

    Ok I was able to verify the open question when merging another branch. gh uses the primary address of the github account to create the merge commit when merging the pull request. IMHO this should not be the case if there is a .github/config in the current working copy. Then this email.name/email.user pair should take precedence.

  3. mislav commented on Feb 24, 2021

    @mislav
    Contributor

    Thanks for the suggestion! Right now it's not possible to change the author when using pr merge, but we might make it possible in the future: #1450

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions