git pushes with wrong user from terminal

前端 未结 22 1504
夕颜
夕颜 2020-12-07 07:51

I have an issue with git and my terminal.

Here\'s a gallery to show you my issue : http://imgur.com/a/6RrEY

When I push commits from my terminal, git says I

22条回答
  •  我在风中等你
    2020-12-07 08:10

    The comment from @bolun-zhang helped me finally solve this:

    "github identifies you by the ssh key it sees, not by any setting from git"

    IMHO, this is inaccurate and very misleading/wrong. When you are using SSH to interact with github, the permissions are checked by the SSH. However, github determines the authorship of commits based on the email gitconfig regardless of the SSH key.

    For me, this turned out to be completely accurate. Reguardless of what I set in ~/.ssh/config even using: export GIT_SSH_COMMAND="ssh -i ~/.ssh/some-key", an alternate username was still being selected.

    The problem and solution was that git config user.email was matched to the alternate email of another github user.

    After removing that email from the other github user, the commit worked fine.

    Ultimately, as @venkatesh-murugesh pointed out, you need to set:

    git config user.email
    

    To match the email address of the github user account that should own the commit.

    Of course, you'll want to use ~/.ssh/config or GIT_SSH_COMMAND to make sure that SSH is using the correct key. Test it with:

    ssh -T git@github.com
    

提交回复
热议问题