4

Since a few weeks, my commits on GitHub are listed under author muheim instead of jmuheim. I have no idea how this changed, and I'd like to change it back to jmuheim, but I have no idea how to track this.

I'm on macOS and my password is saved in the keychain. But I don't find any account muheim in there, only jmuheim.

I have an id_rsa.pub on my system, and I'm pretty sure that it's mapped to jmuheim on GitHub, but I'm not really an SSH expert.

So why and how does git push use the muheim user? If I can't fix this, I will try to delete the muheim user (which is a legacy user I used some years ago), but I hope that someone can help me track this problem down.

Joshua Muheim
  • 12,617
  • 9
  • 76
  • 152
  • 1
    What does it say when you do ‘git config —global user.name’ (or check your .gitconfig file) maybe? –  Dec 28 '17 at 19:48
  • It's probably about the email though. I guess you're using the email that is associated with your old account. – pmmaga Dec 28 '17 at 19:49
  • @pmmaga: Thanks a lot, this was the problem! I removed the email from `muheim` and attached it to `jmuheim`, now all commits seem to automatically have been re-wired to `jmuheim`! Is this normal? This feels very strange to me... – Joshua Muheim Dec 29 '17 at 16:34
  • You had selected the right answer: I have edited it to explain why moving the email address was enough. – VonC Jan 08 '18 at 09:07

2 Answers2

1

The authentication has nothing to do with the user.name/user.email used for commits.

Check your git config user.name value: you can change it back to the old value.

And you can replace your user name/email for old commits.
(Although that will rewrite the history of the repo: if you are the only one working with it, this is not important)

Do check your git remote -v value as well: if this is an https URL, your id_rsa.pub public SSH key would not be used anyway.

But: if your commit are pushed to the right new-user/repo, then yes, simply changing the user.email would be enough for new commits to be attached to the right user.
You can change that globally, or, if you are managing more than one user, just for that repo:

 cd /path/to/repo
 git config user.email email-of-second-GitHub-account

See more at "Why are my commits linked to the wrong user?".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

You can set your global username and user email on your computer with:

git config --global user.name jmuheim
git config --global user.email jmuheim@example.com

If you want to change the previous commits it'll get a little bit more complicated. Be aware that changing the author information will make it impossible to merge pull requests or forks with the previous author information, since git will tell you those are completely different. Anyway GitHub kindly provides a tutorial for changing the email after changing it to search for the "wrong" name it should look like this:

  1. Create a fresh, bare clone of your repository:

    git clone --bare https://github.com/user/repo.git
    cd repo.git
    
  2. run this script which will change your commiter name and your author name in all commits across all branches from muheim to jmuheim

    #!/bin/sh
    
    git filter-branch --env-filter '
    
    OLD_NAME="muheim"
    CORRECT_NAME="jmuheim"
    
    if [ "$GIT_AUTHOR_NAME" = "$OLD_NAME" ]
    then
        export GIT_COMMITTER_NAME="$CORRECT_NAME"
    fi
    if [ "$GIT_COMMITTER_NAME" = "$OLD_NAME" ]
    then
        export GIT_AUTHOR_NAME="$CORRECT_NAME"
    fi
    ' --tag-name-filter cat -- --branches --tags
    
  3. push to GitHub

    git push --force --tags origin 'refs/heads/*'
    

I suggest to delete the old clone and continue working with a new git clone

you can check your usernames used in the entire repo with:

git log --all --full-history --pretty=format:"%ae  -  %ce  -  %an :%cn"
Night Train
  • 2,383
  • 3
  • 18
  • 35
  • Thanks for your effort. Moving the email address from one GitHub user to the other solved the problem for me, as far as I can see. – Joshua Muheim Jan 08 '18 at 08:56
  • When you run `git log --all --full-history --pretty=format:"%ae - %ce - %an :%cn"` are all your old commits connected to your "new" adress? (Did you want to change that anyway? Probably I missunderstood you ;) ) – Night Train Jan 14 '18 at 13:41