change author name or email in github
Posted by danielApr 26
How to update or change author name or email in git or github
Under rare circumstances, your commits in github might appear in github as if they were made by some one else. I was once the sole contributor in a personal repo and when I pushed a commit to github, I noticed that the in github the commit appeared to come from some other github member and that member was added as a contributor in my repo. The reason for this issue was in my local git config, I had my email address as “user@localhost.localdomain”. Apparently github links your commit to whoever setup that email address to their GitHub account.
Here is the steps and a script that you can run to fix this –
1. Clone your github repo to your local file system.
2. change to the cloned directory
3. Add below shell script to your repo directory and run it –
Make sure to update the first three variables OLD_EMAIL, CORRECT_NAME, and CORRECT_EMAIL to appropriate values.
#!/bin/sh git filter-branch --env-filter ' OLD_EMAIL="ADD_EMAIL_TO_BE_REMOVED@HERE.COM" CORRECT_NAME="NEW_CORRECT_NAME" CORRECT_EMAIL="NEW_CORRECT_EMAIL@HERE.COM" if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] then export GIT_COMMITTER_NAME="$CORRECT_NAME" export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" fi if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] then export GIT_AUTHOR_NAME="$CORRECT_NAME" export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" fi ' --tag-name-filter cat -- --branches --tags
4. Run ‘git log’ to review the author information and if everything looks good –
git push --force --tags origin 'refs/heads/*'
5. delete the cloned directory from your local file system.
References –
https://help.github.com/articles/why-are-my-commits-linked-to-the-wrong-user/
7 comments
You must be logged in to post a comment.