Talentedunicorn logo

Changing author information on a git commit

Last updated

There might be times where you need to “rewrite” history on Git. The most common case is updating the commit message to fix typos or change the message, but there might be times one would want to update the author information - this is how you go about it.

Do not do this on published/pushed commits (unless you know what you are doing)

To change the author of the last commit:

git commit --amend --author "NAME <EMAIL_ADDRESS>"

And that’s it, your commit author will be updated. For earlier commits, you could rebase then run commit amend.

Extra git tip: Rebasing the first commit of a repository

Usually rebase looks like git rebase -i COMMIT_TO_START_FROM but if you wanted to change the first commit COMMIT_TO_START_FROM can’t be the commit you are changing (first commit). To be able to do that the command changes to: git rebase -i --root. ;)