You’ve pushed your code to GitHub/GitLab, but didn’t set the correct author’s email - what now?

When you take a look at the remote code repository (GitHub, GitLab, or similar), the commit is linked to the wrong user.

Fix single git commit with the wrong email address/user name

  1. Fix the git configuration in your terminal (local):

    git config "Your name"
    git config ""
  2. Rebase

    git rebase -i HEAD~1

    An editor window pops up where the commit is marked as pick - change it to edit and save.

  3. Git Amend

    git commit --amend --reset-author
  4. Finish the rebase

    git rebase --continue
  5. Push to the remote repository

    git push -f origin master


You can also work with git filter-branch to fix the complete history.
This operation is unsafe, so proceed with care.

git filter-branch --env-filter 'export GIT_AUTHOR_EMAIL="";GIT_AUTHOR_NAME="correct name"'
git push -f origin master

Here’s a script that also corrects the committer:


## Credits:

git filter-branch -f --env-filter "
  " HEAD

Then push to the remote repository: git push -f origin master.

Further Reading