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.
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? ".
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:
Create a fresh, bare clone of your repository:
git clone --bare https://github.com/user/repo.git cd repo.git
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
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"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.