Change author of last commit in git

If you use multiple emails in your repos (ex. work and private) you may have encountered a situation where your commit was rejected from the remote repository, due to bad email used. In order to fix that all you need to do is to set the correct e-mail for current repository:

git config user.email "your_correct@email.com"

and then, reset the author of the last commit:

git commit --amend --reset-author --no-edit

This command can also be used with git rebase -i on edited commits.

Leave a Reply

Your email address will not be published. Required fields are marked *